Skip to content

Commit 2ffab13

Browse files
committed
Add support for TLS and namespace options
Signed-off-by: Greg Haskins <[email protected]>
1 parent c58084c commit 2ffab13

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

src/manetu/temporal_benchmark/main.clj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434
["-v" "--version" "Print version info and exit"]
3535
[nil "--temporal-target HOSTPORT" "The host:port of the Temporal cluster"
3636
:default "localhost:7233"]
37+
[nil "--temporal-namespace NAMESPACE" "The Temporal namespace to use"
38+
:default "default"]
39+
[nil "--temporal-tls ENABLED" "Enable TLS for Temporal connection"
40+
:default false]
41+
[nil "--temporal-ca PATH" "Path to a PEM for CA trust-root for Temporal cluster"]
3742
[nil "--temporal-taskqueue QUEUENAME" "The temporal taskqueue to use"
3843
:default "temporal-benchmark"]
3944
["-l" "--log-level LEVEL" loglevel-description

src/manetu/temporal_benchmark/utils.clj

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
(:require [clojure.string :as string]
55
[clojure.tools.cli :refer [parse-opts]]
66
[slingshot.slingshot :refer [throw+ try+]]
7-
[temporal.client.core :as c]))
7+
[temporal.client.core :as c]
8+
[temporal.tls :as tls]))
89

910
(def tool-name "temporal-benchmark")
1011

@@ -35,18 +36,24 @@
3536
(defn error-exit [error-msg summary]
3637
(exit -1 (str "Error: " error-msg "\n\n") summary))
3738

38-
(defn global-option-error [field usage-summary]
39-
(error-exit (str "global option '" field "' required") usage-summary))
40-
4139
(defn round2
4240
"Round a double to the given precision (number of significant digits)"
4341
[precision ^double d]
4442
(let [factor (Math/pow 10 precision)]
4543
(/ (Math/round (* d factor)) factor)))
4644

45+
(defn new-ssl-context [{:keys [temporal-ca] :as global-options}]
46+
(-> {}
47+
(cond-> temporal-ca (assoc :ca-path temporal-ca))
48+
(tls/new-ssl-context)))
49+
50+
(defn create-client [{:keys [temporal-target temporal-namespace temporal-tls] :as global-options}]
51+
(c/create-client (-> {:target temporal-target
52+
:namespace temporal-namespace}
53+
(cond-> temporal-tls (assoc :ssl-context (new-ssl-context global-options))))))
54+
4755
(defn exec-command
48-
[{:keys [command description options-spec fn]} global-summary
49-
{:keys [temporal-target] :as global-options} args]
56+
[{:keys [command description options-spec fn]} global-summary global-options args]
5057
(let [{{:keys [help] :as local-options} :options
5158
:keys [errors summary]} (parse-opts args (cons ["-h" "--help"] options-spec))
5259
summary (subcommand-usage command description global-summary summary)]
@@ -60,5 +67,5 @@
6067

6168
:else
6269
(let [options (merge global-options local-options)
63-
client (c/create-client {:target temporal-target})]
70+
client (create-client global-options)]
6471
(fn options client)))))

0 commit comments

Comments
 (0)