File tree Expand file tree Collapse file tree 2 files changed +45
-2
lines changed Expand file tree Collapse file tree 2 files changed +45
-2
lines changed Original file line number Diff line number Diff line change 5
5
(:require [promesa.core :as p]
6
6
[temporal.internal.promise :as pt])
7
7
(:import [temporal.internal.promise PromiseAdapter]
8
- [io.temporal.workflow Promise]))
8
+ [io.temporal.workflow Workflow Promise]))
9
9
10
10
(defn- ->array
11
11
^" [Lio.temporal.workflow.Promise;" [coll]
@@ -44,4 +44,14 @@ promises returned from [[temporal.activity/invoke]] from within workflow context
44
44
```
45
45
"
46
46
[coll]
47
- (pt/->PromiseAdapter (Promise/anyOf (->array coll))))
47
+ (pt/->PromiseAdapter (Promise/anyOf (->array coll))))
48
+
49
+ (defn resolved
50
+ " Returns a new, fully resolved promise"
51
+ [value]
52
+ (Workflow/newPromise value))
53
+
54
+ (defn rejected
55
+ " Returns a new, rejected promise"
56
+ [^Exception e]
57
+ (Workflow/newFailedPromise e))
Original file line number Diff line number Diff line change
1
+ ; ; Copyright © 2022 Manetu, Inc. All rights reserved
2
+
3
+ (ns temporal.test.sequence
4
+ (:require [clojure.test :refer :all ]
5
+ [promesa.core :as p]
6
+ [taoensso.timbre :as log]
7
+ [temporal.client.core :as c]
8
+ [temporal.workflow :refer [defworkflow ]]
9
+ [temporal.activity :refer [defactivity ] :as a]
10
+ [temporal.test.utils :as t]
11
+ [temporal.promise :as pt]))
12
+
13
+ (use-fixtures :once t/wrap-service)
14
+
15
+ (defactivity greet-activity
16
+ [ctx args]
17
+ (log/info " greet-activity:" args)
18
+ (str " Hi, " args))
19
+
20
+ (defworkflow sequence-workflow
21
+ [ctx _]
22
+ @(-> (pt/resolved true )
23
+ (p/then (fn [_]
24
+ (a/invoke greet-activity " Bob" )))
25
+ (p/then (fn [_]
26
+ (a/invoke greet-activity " Charlie" )))
27
+ (p/then (constantly :ok ))))
28
+
29
+ (deftest the-test
30
+ (testing " Verifies that we can process a promise-chain in sequence"
31
+ (let [workflow (t/create-workflow sequence-workflow)]
32
+ (c/start workflow nil )
33
+ (is (= @(c/get-result workflow) :ok )))))
You can’t perform that action at this time.
0 commit comments