Liking cljdoc? Tell your friends :D

temporal.signals

Methods for managing signals from within workflows

Methods for managing signals from within workflows
raw docstring

<!clj

(<! 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
sourceraw docstring

>!clj

(>! workflow-id signal-name payload)

Sends payload to workflow-id via signal signal-name.

Sends `payload` to `workflow-id` via signal `signal-name`.
sourceraw docstring

create-signal-chanclj

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]]
sourceraw docstring

is-empty?clj

(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
sourceraw docstring

pollclj

(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'
sourceraw docstring

register-signal-handler!clj

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
(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
    ))
```
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close