Job Event Delegate Hooks
This patch was authored and released by @jdmcd.
This release adds a protocol called JobEventDelegate
which allows ends users to "hook" into the status of jobs that are being run. Each notification hook can specify a success handler, an error handler, or both.
To get started, conform an object to JobEventDelegate
and implement any of the methods you'd like:
struct MyEventDelegate: JobEventDelegate {
public func dispatched(job: JobEventData, eventLoop: EventLoop) -> EventLoopFuture<Void> {
eventLoop.future()
}
public func didDequeue(jobId: String, eventLoop: EventLoop) -> EventLoopFuture<Void> {
eventLoop.future()
}
public func success(jobId: String, eventLoop: EventLoop) -> EventLoopFuture<Void> {
eventLoop.future()
}
public func error(jobId: String, error: Error, eventLoop: EventLoop) -> EventLoopFuture<Void> {
eventLoop.future()
}
}
Then, add it in your configuration file:
app.queues.add(MyEventDelegate())
This PR also adds a bunch of trace
logging for better debugging