Skip to content

Commit d5651e6

Browse files
committed
adding curation and updates to configuration types
1 parent 94c1e1c commit d5651e6

File tree

5 files changed

+92
-24
lines changed

5 files changed

+92
-24
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# ``ServiceLifecycle/ServiceGroupConfiguration/LoggingConfiguration``
2+
3+
## Topics
4+
5+
### Creating a logging configuration
6+
7+
- ``init()``
8+
9+
### Inspecting a service group configuration
10+
11+
- ``keys``
12+
- ``Keys-swift.struct``
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# ``ServiceLifecycle/ServiceGroupConfiguration/ServiceConfiguration``
2+
3+
## Topics
4+
5+
### Creating a service configuration
6+
7+
- ``init(service:successTerminationBehavior:failureTerminationBehavior:)``
8+
9+
### Inspecting a service configuration
10+
11+
- ``service``
12+
- ``failureTerminationBehavior``
13+
- ``successTerminationBehavior``
14+
- ``TerminationBehavior``
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# ``ServiceLifecycle/ServiceGroupConfiguration``
2+
3+
## Topics
4+
5+
### Creating a service group configuration
6+
7+
- ``init(services:logger:)-([Service],_)``
8+
- ``init(services:logger:)-([ServiceConfiguration],_)``
9+
- ``init(gracefulShutdownSignals:)``
10+
11+
### Creating a new service group configuration with signal handlers
12+
13+
- ``init(services:gracefulShutdownSignals:cancellationSignals:logger:)-([Service],_,_,_)``
14+
- ``init(services:gracefulShutdownSignals:cancellationSignals:logger:)-([ServiceConfiguration],_,_,_)``
15+
16+
### Inspecting the service group services
17+
18+
- ``services``
19+
- ``ServiceConfiguration``
20+
21+
### Inspecting the service group logging
22+
23+
- ``logging``
24+
- ``LoggingConfiguration``
25+
- ``logger``
26+
27+
### Inspecting the service group signal handling
28+
29+
- ``cancellationSignals``
30+
- ``maximumCancellationDuration``
31+
- ``gracefulShutdownSignals``
32+
- ``maximumGracefulShutdownDuration``

Sources/ServiceLifecycle/ServiceGroup.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import Logging
1616
import UnixSignals
1717
import AsyncAlgorithms
1818

19-
/// A ``ServiceGroup`` is responsible for running a number of services, setting up signal handling and signalling graceful shutdown to the services.
19+
/// A service group is responsible for running a number of services, setting up signal handling and signalling graceful shutdown to the services.
2020
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
2121
public actor ServiceGroup: Sendable, Service {
2222
/// The internal state of the ``ServiceGroup``.
@@ -47,7 +47,7 @@ public actor ServiceGroup: Sendable, Service {
4747
/// The current state of the group.
4848
private var state: State
4949

50-
/// Initializes a service group.
50+
/// Creates a service group.
5151
///
5252
/// - Parameters:
5353
/// - configuration: The group's configuration
@@ -68,7 +68,7 @@ public actor ServiceGroup: Sendable, Service {
6868
self.maximumCancellationDuration = configuration._maximumCancellationDuration
6969
}
7070

71-
/// Initializes a service group.
71+
/// Creates a service group.
7272
///
7373
/// - Parameters:
7474
/// - services: The groups's service configurations.
@@ -91,7 +91,7 @@ public actor ServiceGroup: Sendable, Service {
9191
self.init(configuration: configuration)
9292
}
9393

94-
/// Initializes a service group.
94+
/// Creates a service group.
9595
///
9696
/// Use ``init(services:gracefulShutdownSignals:cancellationSignals:logger:)`` instead.
9797
@available(*, deprecated, renamed: "init(services:gracefulShutdownSignals:cancellationSignals:logger:)")
@@ -112,7 +112,7 @@ public actor ServiceGroup: Sendable, Service {
112112
self.maximumCancellationDuration = configuration._maximumCancellationDuration
113113
}
114114

115-
/// Adds a new service to the group.
115+
/// Adds a service to the group.
116116
///
117117
/// If the group is currently running, the added service will be started immediately.
118118
/// If the group is gracefully shutting down, cancelling, or already finished, the added service will not be started.
@@ -134,7 +134,7 @@ public actor ServiceGroup: Sendable, Service {
134134
}
135135
}
136136

137-
/// Adds a new service to the group.
137+
/// Adds a service to the group.
138138
///
139139
/// If the group is currently running, the added service will be started immediately.
140140
/// If the group is gracefully shutting down, cancelling, or already finished, the added service will not be started.
@@ -155,8 +155,8 @@ public actor ServiceGroup: Sendable, Service {
155155
}
156156

157157
/// Runs all the services by spinning up a child task per service.
158-
/// Furthermore, this method sets up the correct signal handlers
159-
/// for graceful shutdown.
158+
///
159+
/// Furthermore, this method sets up the correct signal handlers for graceful shutdown.
160160
public func run(file: String = #file, line: Int = #line) async throws {
161161
switch self.state {
162162
case .initial(var services):

Sources/ServiceLifecycle/ServiceGroupConfiguration.swift

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@ import UnixSignals
1717

1818
let deprecatedLoggerLabel = "service-lifecycle-deprecated-method-logger"
1919

20-
/// The configuration for the ``ServiceGroup``.
20+
/// The configuration for the service group.
2121
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
2222
public struct ServiceGroupConfiguration: Sendable {
2323
/// The group's logging configuration.
2424
public struct LoggingConfiguration: Sendable {
25+
/// The keys to use for logging
2526
public struct Keys: Sendable {
2627
/// The logging key used for logging the unix signal.
2728
public var signalKey = "sl-signal"
@@ -36,19 +37,23 @@ public struct ServiceGroupConfiguration: Sendable {
3637
/// The logging key used for logging an error.
3738
public var errorKey = "sl-error"
3839

39-
/// Initializes a new ``ServiceGroupConfiguration/LoggingConfiguration/Keys``.
40+
/// Creates a new set of keys.
4041
public init() {}
4142
}
4243

4344
/// The keys used for logging.
4445
public var keys = Keys()
4546

46-
/// Initializes a new ``ServiceGroupConfiguration/LoggingConfiguration``.
47+
/// Creates a new logging configuration.
4748
public init() {}
4849
}
49-
50+
51+
/// A service configuration.
5052
public struct ServiceConfiguration: Sendable {
51-
/// The behavior to follow when the service finishes its ``Service/run()`` method via returning or throwing.
53+
54+
/// The behavior to follow when the service finishes running.
55+
///
56+
/// This describes what the service lifecycle code does when a service's run method returns or throws.
5257
public struct TerminationBehavior: Sendable, CustomStringConvertible {
5358
internal enum _TerminationBehavior {
5459
case cancelGroup
@@ -57,11 +62,15 @@ public struct ServiceGroupConfiguration: Sendable {
5762
}
5863

5964
internal let behavior: _TerminationBehavior
60-
65+
66+
/// Cancel the service group.
6167
public static let cancelGroup = Self(behavior: .cancelGroup)
68+
/// Gracefully shut down the service group.
6269
public static let gracefullyShutdownGroup = Self(behavior: .gracefullyShutdownGroup)
70+
/// Ignore the completion of the service.
6371
public static let ignore = Self(behavior: .ignore)
64-
72+
73+
/// A string representation of the behavior when a service finishes running.
6574
public var description: String {
6675
switch self.behavior {
6776
case .cancelGroup:
@@ -76,17 +85,17 @@ public struct ServiceGroupConfiguration: Sendable {
7685

7786
/// The service to which the initialized configuration applies.
7887
public var service: any Service
79-
/// The behavior when the service returns from its ``Service/run()`` method.
88+
/// The behavior when the service returns from its run method.
8089
public var successTerminationBehavior: TerminationBehavior
81-
/// The behavior when the service throws from its ``Service/run()`` method.
90+
/// The behavior when the service throws from its run method.
8291
public var failureTerminationBehavior: TerminationBehavior
8392

84-
/// Initializes a new ``ServiceGroupConfiguration/ServiceConfiguration``.
93+
/// Initializes a new service configuration.
8594
///
8695
/// - Parameters:
8796
/// - service: The service to which the initialized configuration applies.
88-
/// - successTerminationBehavior: The behavior when the service returns from its ``Service/run()`` method.
89-
/// - failureTerminationBehavior: The behavior when the service throws from its ``Service/run()`` method.
97+
/// - successTerminationBehavior: The behavior when the service returns from its run method.
98+
/// - failureTerminationBehavior: The behavior when the service throws from its run method.
9099
public init(
91100
service: any Service,
92101
successTerminationBehavior: TerminationBehavior = .cancelGroup,
@@ -166,7 +175,7 @@ public struct ServiceGroupConfiguration: Sendable {
166175

167176
internal var _maximumCancellationDuration: (secondsComponent: Int64, attosecondsComponent: Int64)?
168177

169-
/// Initializes a new ``ServiceGroupConfiguration``.
178+
/// Creates a new service group configuration from the service configurations you provide.
170179
///
171180
/// - Parameters:
172181
/// - services: The groups's service configurations.
@@ -179,7 +188,7 @@ public struct ServiceGroupConfiguration: Sendable {
179188
self.logger = logger
180189
}
181190

182-
/// Initializes a new ``ServiceGroupConfiguration``.
191+
/// Creates a new service group configuration from service configurations you provide with cancellation and shutdown signals.
183192
///
184193
/// - Parameters:
185194
/// - services: The groups's service configurations.
@@ -198,7 +207,7 @@ public struct ServiceGroupConfiguration: Sendable {
198207
self.cancellationSignals = cancellationSignals
199208
}
200209

201-
/// Initializes a new ``ServiceGroupConfiguration``.
210+
/// Creates a new service group configuration from services you provide.
202211
///
203212
/// - Parameters:
204213
/// - services: The groups's services.
@@ -211,7 +220,7 @@ public struct ServiceGroupConfiguration: Sendable {
211220
self.logger = logger
212221
}
213222

214-
/// Initializes a new ``ServiceGroupConfiguration``.
223+
/// Creates a new service group configuration from services you provide with cancellation and shutdown signals..
215224
///
216225
/// - Parameters:
217226
/// - services: The groups's services.
@@ -230,6 +239,7 @@ public struct ServiceGroupConfiguration: Sendable {
230239
self.cancellationSignals = cancellationSignals
231240
}
232241

242+
/// Initializes a new service group configuration.
233243
@available(*, deprecated)
234244
public init(gracefulShutdownSignals: [UnixSignal]) {
235245
self.services = []

0 commit comments

Comments
 (0)