|
8 | 8 | [temporal.activity :refer [defactivity] :as a] |
9 | 9 | [temporal.promise :as tp] |
10 | 10 | [temporal.client.worker :as worker] |
| 11 | + [manetu.temporal-benchmark.metrics :as metrics] |
11 | 12 | [manetu.temporal-benchmark.utils :refer [exec-command]])) |
12 | 13 |
|
13 | 14 | (def command "worker") |
|
49 | 50 | :default 1000 |
50 | 51 | :parse-fn parse-long |
51 | 52 | :validate [pos? "Must be a positive integer"]] |
| 53 | + [nil "--[no-]metrics-enabled" "Enable metrics endpoint (see --metrics-port)" |
| 54 | + :default false] |
| 55 | + [nil "--metrics-port NUM" "The HTTP port for metrics, when enabled" |
| 56 | + :default 8080 |
| 57 | + :parse-fn parse-long |
| 58 | + :validate [pos? "Must be a positive integer"]] |
52 | 59 | [nil "--[no-]using-virtual-workflow-threads" "Use Virtual Threads for workflow threads (requires JDK 21+)" |
53 | 60 | :default p.exec/vthreads-supported?]]) |
54 | 61 |
|
55 | | -(defn start [options client] |
56 | | - (worker/start client |
57 | | - (-> (select-keys options [:temporal-taskqueue |
58 | | - :max-concurrent-activity-task-pollers |
59 | | - :max-concurrent-activity-execution-size |
60 | | - :max-concurrent-workflow-task-pollers |
61 | | - :max-concurrent-workflow-task-execution-size]) |
62 | | - (rename-keys {:temporal-taskqueue :task-queue})) |
63 | | - (select-keys options [:max-workflow-thread-count |
64 | | - :workflow-cache-size |
65 | | - :using-virtual-workflow-threads]))) |
| 62 | +(defn start [{:keys [metrics-enabled metrics-port] :as options} client] |
| 63 | + (let [mctx (when metrics-enabled (metrics/start metrics-port)) |
| 64 | + wctx (worker/start client |
| 65 | + (-> (select-keys options [:temporal-taskqueue |
| 66 | + :max-concurrent-activity-task-pollers |
| 67 | + :max-concurrent-activity-execution-size |
| 68 | + :max-concurrent-workflow-task-pollers |
| 69 | + :max-concurrent-workflow-task-execution-size]) |
| 70 | + (rename-keys {:temporal-taskqueue :task-queue})) |
| 71 | + (select-keys options [:max-workflow-thread-count |
| 72 | + :workflow-cache-size |
| 73 | + :using-virtual-workflow-threads]))] |
| 74 | + {:mctx mctx :wctx wctx})) |
66 | 75 |
|
67 | | -(def stop worker/stop) |
| 76 | +(defn stop [{:keys [mctx wctx]}] |
| 77 | + (some-> mctx metrics/stop) |
| 78 | + (some-> wctx worker/stop)) |
68 | 79 |
|
69 | 80 | (defn exec [options client] |
70 | | - (let [w (start options client)] |
| 81 | + (let [ctx (start options client)] |
71 | 82 | (println "Worker running. Press CNTL-C to exit") |
72 | 83 | (deref (promise)) |
73 | | - (worker/stop w))) |
| 84 | + (stop ctx))) |
74 | 85 |
|
75 | 86 | (def spec {:description description |
76 | 87 | :fn (partial exec-command {:command command |
|
0 commit comments