Liking cljdoc? Tell your friends :D

temporal.activity

Methods for defining and invoking activity tasks

Methods for defining and invoking activity tasks
raw docstring

defactivitycljmacro

(defactivity name params* & body)

Defines a new activity, similar to defn, expecting a 2-arity parameter list and body. Should evaluate to something serializable, which will be available to the invoke caller, or to a core.async channel (See Async Mode below).

Async Mode:

Returning a core.async channel places the activity into Asynchronous mode, where the result may be resolved at a future time by sending a single message on the channel. Sending a Throwable will signal a failure of the activity. Any other value will be serialized and returned to the caller.

Arguments:

(defactivity greet-activity
    [ctx {:keys [name] :as args}]
    (str "Hi, " name))
Defines a new activity, similar to defn, expecting a 2-arity parameter list and body.  Should evaluate to something
serializable, which will be available to the [[invoke]] caller, or to a core.async channel (See Async Mode below).

#### Async Mode:
Returning a core.async channel places the activity into
[Asynchronous](https://docs.temporal.io/java/activities/#asynchronous-activity-completion) mode, where the result may
be resolved at a future time by sending a single message on the channel.  Sending a
[Throwable](https://docs.oracle.com/javase/7/docs/api/java/lang/Throwable.html) will signal a failure of the activity.
Any other value will be serialized and returned to the caller.

Arguments:

- `ctx`: Context passed through from [[temporal.client.worker/start]]
- `args`: Passed from 'params' of [[invoke]]

```clojure
(defactivity greet-activity
    [ctx {:keys [name] :as args}]
    (str "Hi, " name))
```
sourceraw docstring

invokeclj

(invoke activity params)
(invoke activity params options)

Invokes 'activity' with 'params' from within a workflow context. Returns a promise that when derefed will resolve to the evaluation of the defactivity once the activity concludes.

(defactivity my-activity
   [ctx {:keys [foo] :as args}]
   ...)

(invoke my-activity {:foo "bar"} {:start-to-close-timeout (Duration/ofSeconds 3))
Invokes 'activity' with 'params' from within a workflow context.  Returns a promise that when derefed will resolve to
the evaluation of the defactivity once the activity concludes.

```clojure
(defactivity my-activity
   [ctx {:keys [foo] :as args}]
   ...)

(invoke my-activity {:foo "bar"} {:start-to-close-timeout (Duration/ofSeconds 3))
```
sourceraw docstring

local-invokeclj

(local-invoke activity params)
(local-invoke activity params options)

Invokes 'activity' with 'params' from within a workflow context as a Local Activity. Returns a promise that when derefed will resolve to the evaluation of the defactivity once the activity concludes.

(defactivity my-activity
   [ctx {:keys [foo] :as args}]
   ...)

(local-invoke my-activity {:foo "bar"} {:start-to-close-timeout (Duration/ofSeconds 3))
Invokes 'activity' with 'params' from within a workflow context as a [Local Activity](https://docs.temporal.io/concepts/what-is-a-local-activity/).  Returns a promise that when
derefed will resolve to the evaluation of the defactivity once the activity concludes.

```clojure
(defactivity my-activity
   [ctx {:keys [foo] :as args}]
   ...)

(local-invoke my-activity {:foo "bar"} {:start-to-close-timeout (Duration/ofSeconds 3))
```
sourceraw docstring

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

× close