Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject io.github.manetu/temporal-sdk "1.4.1-SNAPSHOT"
(defproject io.github.manetu/temporal-sdk "1.5.0-SNAPSHOT"
:description "A Temporal SDK for Clojure"
:url "https://github.com/manetu/temporal-clojure-sdk"
:license {:name "Apache License 2.0"
Expand All @@ -13,8 +13,8 @@
[lein-codox "0.10.8"]]
:dependencies [[org.clojure/clojure "1.12.0"]
[org.clojure/core.async "1.7.701"]
[io.temporal/temporal-sdk "1.28.3"]
[io.temporal/temporal-testing "1.28.3"]
[io.temporal/temporal-sdk "1.31.0"]
[io.temporal/temporal-testing "1.31.0"]
[com.taoensso/encore "3.139.0"]
[com.taoensso/timbre "6.6.1"]
[com.taoensso/nippy "3.4.2"]
Expand All @@ -36,5 +36,5 @@
:cloverage {:runner :eftest
:runner-opts {:multithread? false
:fail-fast? true}
:fail-threshold 91
:fail-threshold 90
:ns-exclude-regex [#"temporal.client.worker"]})
26 changes: 22 additions & 4 deletions src/temporal/client/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,41 @@
(:import [java.time Duration]
[io.temporal.client WorkflowClient WorkflowStub]))

(defn- ^:no-doc create-client*
[service-stub options]
(WorkflowClient/newInstance service-stub (copts/workflow-client-options-> options)))

(defn create-client-async
"
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-client-async {}))
([options]
(create-client* (copts/service-stub-> options) options)))

(defn create-client
"
Creates a new client instance suitable for implementing Temporal workers (See [[temporal.client.worker/start]]) or
workflow clients (See [[create-workflow]]).
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`: Connection timeout as a [Duration](https://docs.oracle.com/javase/8/docs/api//java/time/Duration.html) (default: 5s)
- `timeout`: Optional connection timeout as a [Duration](https://docs.oracle.com/javase/8/docs/api//java/time/Duration.html) (Default: 5s).

"
([] (create-client {}))
([options]
(create-client options (Duration/ofSeconds 5)))
([options timeout]
(let [service (copts/service-stub-> options timeout)]
(WorkflowClient/newInstance service (copts/workflow-client-options-> options)))))
(create-client* (copts/service-stub-> options timeout) options)))

(defn create-workflow
"
Expand Down
17 changes: 14 additions & 3 deletions src/temporal/client/options.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
(:import [io.temporal.client WorkflowClientOptions WorkflowClientOptions$Builder]
[io.temporal.common.interceptors WorkflowClientInterceptorBase]
[io.temporal.client.schedules ScheduleClientOptions ScheduleClientOptions$Builder]
[io.temporal.serviceclient WorkflowServiceStubs WorkflowServiceStubsOptions WorkflowServiceStubsOptions$Builder]))
[io.temporal.serviceclient WorkflowServiceStubs WorkflowServiceStubsOptions WorkflowServiceStubsOptions$Builder]
[io.temporal.authorization AuthorizationTokenSupplier]))

(def workflow-client-options
"
Expand Down Expand Up @@ -46,6 +47,12 @@
^ScheduleClientOptions [params]
(u/build (ScheduleClientOptions/newBuilder (ScheduleClientOptions/getDefaultInstance)) schedule-client-options params))

(defn ^:no-doc apikey-auth-fn->
^AuthorizationTokenSupplier [f]
(reify AuthorizationTokenSupplier
(supply [_]
(f))))

(def stub-options
"
`WorkflowServiceStubsOptions` configuration map (See [[temporal.client.core/create-client]] or [[temporal.client.schedule/create-client]])
Expand All @@ -54,6 +61,7 @@
| ------------------------- | --------------------------------------------------------------------------- | ------------ | ------- |
| :channel | Sets gRPC channel to use. Exclusive with target and sslContext | [ManagedChannel](https://grpc.github.io/grpc-java/javadoc/io/grpc/ManagedChannel.html) | |
| :ssl-context | Sets gRPC SSL Context to use (See [[temporal.tls/new-ssl-context]]) | [SslContext](https://netty.io/4.0/api/io/netty/handler/ssl/SslContext.html) | |
| :api-key-fn | Sets [a function to return an API Key](https://docs.temporal.io/develop/java/temporal-client#connect-to-temporal-cloud-api-key) for authentication to Temporal Cloud | A 0-arity (fn) that evaluates to an API Key string | |
| :enable-https | Sets option to enable SSL/TLS/HTTPS for gRPC | boolean | false |
| :rpc-timeout | Sets the rpc timeout value for non query and non long poll calls | [Duration](https://docs.oracle.com/javase/8/docs/api//java/time/Duration.html) | 10s |
| :rpc-long-poll-timeout | Sets the rpc timeout value | [Duration](https://docs.oracle.com/javase/8/docs/api//java/time/Duration.html) | 60s |
Expand All @@ -70,6 +78,7 @@
"
{:channel #(.setChannel ^WorkflowServiceStubsOptions$Builder %1 %2)
:ssl-context #(.setSslContext ^WorkflowServiceStubsOptions$Builder %1 %2)
:api-key-fn #(.addApiKey ^WorkflowServiceStubsOptions$Builder %1 (apikey-auth-fn-> %2))
:enable-https #(.setEnableHttps ^WorkflowServiceStubsOptions$Builder %1 %2)
:target #(.setTarget ^WorkflowServiceStubsOptions$Builder %1 %2)
:rpc-timeout #(.setRpcTimeout ^WorkflowServiceStubsOptions$Builder %1 %2)
Expand All @@ -89,5 +98,7 @@
(u/build (WorkflowServiceStubsOptions/newBuilder) stub-options params))

(defn service-stub->
[options timeout]
(WorkflowServiceStubs/newConnectedServiceStubs (stub-options-> options) timeout))
([options]
(WorkflowServiceStubs/newServiceStubs (stub-options-> options)))
([options timeout]
(WorkflowServiceStubs/newConnectedServiceStubs (stub-options-> options) timeout)))