Skip to content

Commit bc35ca5

Browse files
authored
Fix the README example (#40)
1 parent 4edb0c8 commit bc35ca5

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

README.md

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff 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
```

0 commit comments

Comments
 (0)