File tree Expand file tree Collapse file tree 1 file changed +25
-8
lines changed Expand file tree Collapse file tree 1 file changed +25
-8
lines changed Original file line number Diff line number Diff line change @@ -163,14 +163,31 @@ struct MyApp {
163163 logger : Logger (label : " client" )
164164 )
165165
166- // Execute workflow
167- let result = try await client.executeWorkflow (
168- GreetingWorkflow.self ,
169- options : .init (id : " greeting-1" , taskQueue : " greeting-queue" ),
170- input : " World"
171- )
172-
173- print (result) // "Hello, World!"
166+ try await withThrowingTaskGroup { group in
167+ group.addTask {
168+ try await worker.run ()
169+ }
170+
171+ group.addTask {
172+ try await client.run ()
173+ }
174+
175+ // Wait for the worker and client to run
176+ try await Task.sleep (for : .seconds (1 ))
177+
178+ // Execute workflow
179+ print (" Executing workflow" )
180+ let result = try await client.executeWorkflow (
181+ GreetingWorkflow.self ,
182+ options : .init (id : " greeting-1" , taskQueue : " greeting-queue" ),
183+ input : " World"
184+ )
185+
186+ print (result) // "Hello, World!"
187+
188+ // Cancel the client and worker
189+ group.cancelAll ()
190+ }
174191 }
175192}
176193```
You can’t perform that action at this time.
0 commit comments