Skip to content

Commit

Permalink
Expose ActivityInfo in public API
Browse files Browse the repository at this point in the history
Signed-off-by: Greg Haskins <[email protected]>
  • Loading branch information
ghaskins committed Jan 30, 2024
1 parent d533226 commit e9fb87a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/temporal/activity.clj
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ along with the Activity Task for the next retry attempt and can be extracted by
(log/trace "get-heartbeat-details:" v)
v)))

(defn get-info
"Returns information about the Activity execution"
[]
(a/get-info))

(defn- complete-invoke
[activity result]
(log/trace activity "completed with" (count result) "bytes")
Expand Down
7 changes: 4 additions & 3 deletions src/temporal/internal/activity.clj
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@
:activity-type (.getActivityType d)}))

(defn get-info []
(-> (Activity/getExecutionContext)
(.getInfo)
(d/datafy)))
(->> (Activity/getExecutionContext)
(.getInfo)
(d/datafy)
(into {})))

(defn get-annotation
^String [x]
Expand Down
26 changes: 26 additions & 0 deletions test/temporal/test/activity_info.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
;; Copyright © Manetu, Inc. All rights reserved

(ns temporal.test.activity-info
(:require [clojure.test :refer :all]
[temporal.client.core :as c]
[temporal.workflow :refer [defworkflow]]
[temporal.activity :refer [defactivity] :as a]
[temporal.test.utils :as t]))

(use-fixtures :once t/wrap-service)

(defactivity getinfo-activity
[ctx args]
(a/get-info))

(defworkflow getinfo-workflow
[args]
@(a/invoke getinfo-activity args))

(deftest the-test
(testing "Verifies that we can retrieve our activity-id"
(let [workflow (t/create-workflow getinfo-workflow)]
(c/start workflow {})
(let [{:keys [activity-id]} @(c/get-result workflow)]
(is (some? activity-id))))))

0 comments on commit e9fb87a

Please sign in to comment.