Methods for client interaction with Temporal
Methods for client interaction with Temporal
(>! {:keys [stub] :as workflow} signal-name params)Sends 'params' as a signal 'signal-name' to 'workflow'
(>! workflow ::my-signal {:msg "Hi"})
Sends 'params' as a signal 'signal-name' to 'workflow'
```clojure
(>! workflow ::my-signal {:msg "Hi"})
```(cancel {:keys [stub] :as workflow})Gracefully cancels 'workflow'
(cancel workflow)
Gracefully cancels 'workflow' ```clojure (cancel workflow) ```
(create-client)(create-client options)(create-client options timeout)Creates a new client instance suitable for implementing Temporal workers (See temporal.client.worker/start) or
workflow clients (See create-workflow). The caller is blocked while the connection is verified for up to the
specified timeout duration, or 5s if not specified.
Arguments:
options: Options for configuring the WorkflowClient (See temporal.client.options/workflow-client-options and temporal.client.options/stub-options)timeout: Optional connection timeout as a Duration (Default: 5s).Creates a new client instance suitable for implementing Temporal workers (See [[temporal.client.worker/start]]) or workflow clients (See [[create-workflow]]). The caller is blocked while the connection is verified for up to the specified timeout duration, or 5s if not specified. Arguments: - `options`: Options for configuring the `WorkflowClient` (See [[temporal.client.options/workflow-client-options]] and [[temporal.client.options/stub-options]]) - `timeout`: Optional connection timeout as a [Duration](https://docs.oracle.com/javase/8/docs/api//java/time/Duration.html) (Default: 5s).
(create-client-async)(create-client-async options)Creates a new client instance suitable for implementing Temporal workers (See temporal.client.worker/start) or
workflow clients (See create-workflow). Will not verify the connection before returning.
Arguments:
options: Options for configuring the WorkflowClient (See temporal.client.options/workflow-client-options and temporal.client.options/stub-options)Creates a new client instance suitable for implementing Temporal workers (See [[temporal.client.worker/start]]) or workflow clients (See [[create-workflow]]). Will not verify the connection before returning. Arguments: - `options`: Options for configuring the `WorkflowClient` (See [[temporal.client.options/workflow-client-options]] and [[temporal.client.options/stub-options]])
(create-workflow client workflow-id)(create-workflow client workflow options)Create a new workflow-stub instance, suitable for managing and interacting with a workflow through it's lifecycle.
N.B.: The workflow will remain in an uninitialized and idle state until explicitly started with either (start) or
(signal-with-start).
(defworkflow my-workflow
[ctx args]
...)
(let [w (create client my-workflow {:task-queue ::my-task-queue})]
;; do something with the instance 'w')
Create a new workflow-stub instance, suitable for managing and interacting with a workflow through it's lifecycle.
*N.B.: The workflow will remain in an uninitialized and idle state until explicitly started with either ([[start]]) or
([[signal-with-start]]).*
```clojure
(defworkflow my-workflow
[ctx args]
...)
(let [w (create client my-workflow {:task-queue ::my-task-queue})]
;; do something with the instance 'w')
```
(get-result {:keys [stub] :as workflow})Retrieves the final result of 'workflow'. Returns a promise that when derefed will resolve to the evaluation of the defworkflow once the workflow concludes.
(defworkflow my-workflow
[ctx args]
...)
(let [w (create ...)]
(start w ...)
@(get-result w))
Retrieves the final result of 'workflow'. Returns a promise that when derefed will resolve to the evaluation of the defworkflow once the workflow concludes. ```clojure (defworkflow my-workflow [ctx args] ...) (let [w (create ...)] (start w ...) @(get-result w)) ```
(query {:keys [stub] :as workflow} query-type args)Sends query with 'query-type' and 'args' to 'workflow', returns a value.
The query result is computed by a query-handler, registered inside the workflow definition
using temporal.workflow/register-query-handler!.
Arguments:
query-type: keyword (or coerceable into a keyword)args: serializable query params(query workflow ::my-query {:foo "bar"})
Sends query with 'query-type' and 'args' to 'workflow', returns a value.
The query result is computed by a query-handler, registered inside the workflow definition
using [[temporal.workflow/register-query-handler!]].
Arguments:
- `query-type`: keyword (or coerceable into a keyword)
- `args`: serializable query params
```clojure
(query workflow ::my-query {:foo "bar"})
```(signal-with-start {:keys [stub] :as workflow}
signal-name
signal-params
wf-params)Signals 'workflow' with 'signal-params' on signal 'signal-name', starting it if not already running. 'wf-params' are used as workflow start arguments if the workflow needs to be started
Signals 'workflow' with 'signal-params' on signal 'signal-name', starting it if not already running. 'wf-params' are used as workflow start arguments if the workflow needs to be started
(start {:keys [stub] :as workflow} params)Starts 'worklow' with 'params'
Starts 'worklow' with 'params'
(terminate {:keys [stub] :as workflow} reason params)Forcefully terminates 'workflow'
(terminate workflow "unresponsive", {})
Forcefully terminates 'workflow'
```clojure
(terminate workflow "unresponsive", {})
```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 |