jonhoo / faktory-rs

Rust bindings for Faktory clients and workers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Handle signals

jonhoo opened this issue · comments

We should add a dependency on ctrlc so that the worker can be told to cleanly exit when run_to_completion is called. The implementation will likely be fairly straightforward, essentially just storing STATUS_TERMINATING and letting the heartbeat thread do the cleanup (including failing the currently execution job). This may require some minor changes to make the heartbeat thread recognize that this is indeed a forced exit.

We may also want to allow the user to opt-in to signal handling for run, although that's less clear (we might instead want to return some kind of handle that the caller can use to signal to exit or wait for termination).

Suggesting to use signal and namely ctrl_c interceptor from tokio eco-system, since we are switching to async.