To initialize a Workflow Client, create an instance of a Workflow client with (create-client), create a Workflow stub with (create-workflow), and invoke the Workflow with (start)). Finally, gather the results of the Workflow with (get-result).
To start a Workflow Execution, your Temporal Server must be running, and your front-end service must be accepting gRPC calls.
You can provide options to (create-client) to establish a connection to the specifics of the Temporal front-end service in your environment.
(create-client {:target "temporal-frontend:7233" :namespace "my-namespace"})
After establishing a successful connection to the Temporal Frontend Service, you may perform operations such as:
As a simple example, for the following Workflow implementation:
(require '[temporal.workflow :refer [defworkflow]])
(require '[temporal.activity :refer [defactivity] :as a])
(defactivity greet-activity
[ctx {:keys [name] :as args}]
(log/info "greet-activity:" args)
(str "Hi, " name))
(defworkflow greeter-workflow
[ctx {:keys [args]}]
(log/info "greeter-workflow:" args)
@(a/invoke greet-activity args))
We can create a client to invoke our Workflow as follows:
(require '[temporal.client.core :as c])
(def task-queue "MyTaskQueue")
(let [client (c/create-client)
workflow (c/create-workflow client greeter-workflow {:queue-name task-queue})]
(c/start workflow {:name "Bob"})
(println @(c/get-result workflow)))
Evaluating this code should result in Hi, Bob
appearing on the console. Note that (get-result) returns a promise, thus requiring a dereference.
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close