Files
Max Desiatov 05031271bf Update TerminationBehavior doc comments and notes (#165)
* Mention `TerminationBehavior` in library adoption docs

`ServiceGroupConfiguration.ServiceConfiguration.TerminationBehavior` did not seem to be mentioned in the docs and specifically library adoption docs gave the impression that cancellation on returning from `run` is the only option.

* Update relevant documentation
2024-01-25 14:24:30 +00:00

29 lines
1.3 KiB
Swift

//===----------------------------------------------------------------------===//
//
// This source file is part of the SwiftServiceLifecycle open source project
//
// Copyright (c) 2023 Apple Inc. and the SwiftServiceLifecycle project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of SwiftServiceLifecycle project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
/// This is the basic protocol that a service has to implement.
public protocol Service: Sendable {
/// This method is called when the ``ServiceGroup`` is starting all the services.
///
/// Concrete implementation should execute their long running work in this method such as:
/// - Handling incoming connections and requests
/// - Background refreshes
///
/// - Important: Returning or throwing from this method indicates the service should stop and will cause the
/// ``ServiceGroup`` to follow behaviors for the child tasks of all other running services specified in
/// ``ServiceGroupConfiguration/ServiceConfiguration/successTerminationBehavior`` and
/// ``ServiceGroupConfiguration/ServiceConfiguration/failureTerminationBehavior``.
func run() async throws
}