maxcountryman / underway

⏳ Durable step functions via Postgres.
Apache License 2.0
72 stars 2 forks source link

use cancellation token for shutdown #32

Closed maxcountryman closed 1 month ago

maxcountryman commented 1 month ago

This refactors worker shutdown to use a cancellation token to signal shutdown. By doing so, we can avoid managing an atomic bool. It also makes it possible to provide addtional methods, such as a shutdown method, on the worker itself to signal shutdown.

maxcountryman commented 1 month ago

/cc @kirillsalykin I ended up using a cancellation token here instead (Notify could also work, but it's not cancel safe and requires pinning to work as I'd want it).

From here we could add shutdown or similar to the worker. Then the job could wrap that. Likewise with the scheduler I think.

Let me know what you think.

kirillsalykin commented 1 month ago

LGTM