我们有一个Vapor API,它使用一个Web Worker、一个队列Worker和一个调度队列Worker.每个工人都有相同的configure(_ app: Application)
功能.
在这个函数中,我希望找到Worker的类型,而不是队列Worker的Web或On.
// configures the worker
public func configure(_ app: Application) throws {
// clear every middleware
app.middleware = .init()
// HERE I want to differentiate the worker
if web worker {
// do that
} else {
// do something other
}
}
在Application
中有没有一种方法或方法可以告诉我它的类型?
我们的主要问题是,我们想要try app.autoMigrate().wait()
,但只对网络工作者.
目前,所有工作人员都在try 迁移数据库,显然,其中两个失败了.