manetu / temporal-clojure-sdk

A Temporal SDK for Clojure
Apache License 2.0
72 stars 10 forks source link

Add register-signal-handler! and signal-channel abstraction #44

Closed ghaskins closed 10 months ago

ghaskins commented 10 months ago

This patch breaks out the signal handling such that the core.async abstraction surrounding signals is now optional. There is a new function:

       temporal.signals/register-signal-handler!

that offers low-level access to the signal callback. The design was inspired by the work of Thomas Moerman (https://github.com/tmoerman) in the Query support

(See https://github.com/manetu/temporal-clojure-sdk/commit/4f052aeecd5d36cac0d1c2e1e95b72b23e5b2be7)

This work prompted another cleanup that I had been meaning to do: the removal of the 'ctx' from the defworkflow. The original design had both defworkflow and defactivity receiving a user supplied 'ctx', but this never made sense for workflows since the context invites non-determinism.

So, the new signature of defworkflow is simply a single-arity function that receives the arguments directly, rather than within a {:keys [signals args]} map. We still support 2-arity clients (for now) with a backwards compatibility check within the macro. This may be removed in a future release, so we print a WARN to signal the developer of the deprecation.