Docs fix - put group.addTask inside the loop (#156)

* Docs fix - put group.addTask inside the loop

* Update How to adopt ServiceLifecycle in applications.md
This commit is contained in:
Honza Dvorsky authored and GitHub committed 2023-08-24 10:09:15 +01:00
1 parent 2becb2433a
commit e4592be5e6
1 file changed
+4 -4
@@ -129,8 +129,8 @@ struct StreamingService: Service {
func run() async throws {
await withDiscardingTaskGroup { group in
group.addTask {
for stream in makeStreams() {
for stream in makeStreams() {
group.addTask {
await streamHandler(stream.requestStream, stream.responseWriter)
}
}
@@ -191,8 +191,8 @@ struct StreamingService: Service {
func run() async throws {
await withDiscardingTaskGroup { group in
group.addTask {
for stream in makeStreams().cancelOnGracefulShutdown() {
for stream in makeStreams().cancelOnGracefulShutdown() {
group.addTask {
await streamHandler(stream.requestStream, stream.responseWriter)
}
}