From 4eaaf079a8d85fd03f7cea62ebb21175d2edba32 Mon Sep 17 00:00:00 2001 From: Franz Busch Date: Thu, 1 Jun 2023 09:03:11 +0200 Subject: [PATCH] Rename `shutdownGracefully` to `triggerGracefulShutdown` on the `ServiceGroup` (#142) --- Sources/ServiceLifecycle/ServiceGroup.swift | 2 +- Tests/ServiceLifecycleTests/ServiceGroupTests.swift | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/ServiceLifecycle/ServiceGroup.swift b/Sources/ServiceLifecycle/ServiceGroup.swift index b765321..e6bd329 100644 --- a/Sources/ServiceLifecycle/ServiceGroup.swift +++ b/Sources/ServiceLifecycle/ServiceGroup.swift @@ -102,7 +102,7 @@ public actor ServiceGroup: Sendable { /// Triggers the graceful shutdown of all services. /// /// This method returns immediately after triggering the graceful shutdown and doesn't wait until the service have shutdown. - public func shutdownGracefully() async { + public func triggerGracefulShutdown() async { switch self.state { case .initial: // We aren't even running so we can stop right away. diff --git a/Tests/ServiceLifecycleTests/ServiceGroupTests.swift b/Tests/ServiceLifecycleTests/ServiceGroupTests.swift index ed27bc8..fa4fdbe 100644 --- a/Tests/ServiceLifecycleTests/ServiceGroupTests.swift +++ b/Tests/ServiceLifecycleTests/ServiceGroupTests.swift @@ -487,7 +487,7 @@ final class ServiceGroupTests: XCTestCase { } } - func testShutdownGracefully() async throws { + func testTriggerGracefulShutdown() async throws { let configuration = ServiceGroupConfiguration(gracefulShutdownSignals: []) let service1 = MockService(description: "Service1") let service2 = MockService(description: "Service2") @@ -508,7 +508,7 @@ final class ServiceGroupTests: XCTestCase { var eventIterator3 = service3.events.makeAsyncIterator() await XCTAsyncAssertEqual(await eventIterator3.next(), .run) - await serviceGroup.shutdownGracefully() + await serviceGroup.triggerGracefulShutdown() // The last service should receive the shutdown signal first await XCTAsyncAssertEqual(await eventIterator3.next(), .shutdownGracefully)