Skip to content

Commit e9fb87a

Browse files
committed
Expose ActivityInfo in public API
Signed-off-by: Greg Haskins <[email protected]>
1 parent d533226 commit e9fb87a

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

src/temporal/activity.clj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ along with the Activity Task for the next retry attempt and can be extracted by
4141
(log/trace "get-heartbeat-details:" v)
4242
v)))
4343

44+
(defn get-info
45+
"Returns information about the Activity execution"
46+
[]
47+
(a/get-info))
48+
4449
(defn- complete-invoke
4550
[activity result]
4651
(log/trace activity "completed with" (count result) "bytes")

src/temporal/internal/activity.clj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,10 @@
5858
:activity-type (.getActivityType d)}))
5959

6060
(defn get-info []
61-
(-> (Activity/getExecutionContext)
62-
(.getInfo)
63-
(d/datafy)))
61+
(->> (Activity/getExecutionContext)
62+
(.getInfo)
63+
(d/datafy)
64+
(into {})))
6465

6566
(defn get-annotation
6667
^String [x]
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
;; Copyright © Manetu, Inc. All rights reserved
2+
3+
(ns temporal.test.activity-info
4+
(:require [clojure.test :refer :all]
5+
[temporal.client.core :as c]
6+
[temporal.workflow :refer [defworkflow]]
7+
[temporal.activity :refer [defactivity] :as a]
8+
[temporal.test.utils :as t]))
9+
10+
(use-fixtures :once t/wrap-service)
11+
12+
(defactivity getinfo-activity
13+
[ctx args]
14+
(a/get-info))
15+
16+
(defworkflow getinfo-workflow
17+
[args]
18+
@(a/invoke getinfo-activity args))
19+
20+
(deftest the-test
21+
(testing "Verifies that we can retrieve our activity-id"
22+
(let [workflow (t/create-workflow getinfo-workflow)]
23+
(c/start workflow {})
24+
(let [{:keys [activity-id]} @(c/get-result workflow)]
25+
(is (some? activity-id))))))
26+

0 commit comments

Comments
 (0)