Methods for managing signals from within workflows
Methods for managing signals from within workflows
(<! signal-chan)(<! signal-chan signal-name)(<! signal-chan signal-name timeout)Light-weight/parking receive of a single message from signal-chan with an optional timeout
Light-weight/parking receive of a single message from signal-chan with an optional timeout
(>! workflow-id signal-name payload)Sends payload to workflow-id via signal signal-name.
Sends `payload` to `workflow-id` via signal `signal-name`.
Registers the calling workflow to receive signals and returns a 'signal-channel' context for use with functions such as amd poll
Registers the calling workflow to receive signals and returns a 'signal-channel' context for use with functions such as [[<!]] amd [[poll]]
(is-empty? signal-chan signal-name)Returns 'true' if 'signal-name' either doesn't exist within signal-chan or exists but has no pending messages
Returns 'true' if 'signal-name' either doesn't exist within signal-chan or exists but has no pending messages
(poll signal-chan signal-name)Non-blocking check of the signal via signal-chan. Consumes and returns a message if found, otherwise returns 'nil'
Non-blocking check of the signal via signal-chan. Consumes and returns a message if found, otherwise returns 'nil'
Registers a DynamicSignalHandler listener that handles signals sent to the workflow such as with >!.
Use inside a workflow definition with 'f' closing over any desired workflow state (e.g. atom) to mutate the workflow state.
Arguments:
f: a 2-arity function, expecting 2 arguments.f arguments:
signal-name: stringargs: params value or data structure(defworkflow signalled-workflow
[{:keys [init] :as args}]
(let [state (atom init)]
(register-signal-handler! (fn [signal-name args]
(when (= signal-name "mysignal")
(update state #(conj % args)))))
;; workflow implementation
))
Registers a DynamicSignalHandler listener that handles signals sent to the workflow such as with [[>!]].
Use inside a workflow definition with 'f' closing over any desired workflow state (e.g. atom) to mutate
the workflow state.
Arguments:
- `f`: a 2-arity function, expecting 2 arguments.
`f` arguments:
- `signal-name`: string
- `args`: params value or data structure
```clojure
(defworkflow signalled-workflow
[{:keys [init] :as args}]
(let [state (atom init)]
(register-signal-handler! (fn [signal-name args]
(when (= signal-name "mysignal")
(update state #(conj % args)))))
;; workflow implementation
))
```cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |