You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Motivation:
README still contains references to old code
Modifications:
Update README to match recent code adjustments
Result:
Correct code snippets in README
Copy file name to clipboardExpand all lines: README.md
+17-17
Original file line number
Diff line number
Diff line change
@@ -41,7 +41,7 @@ let lifecycle = ServiceLifecycle()
41
41
// and passing its `syncShutdownGracefully` function to be called on shutdown
42
42
let eventLoopGroup =MultiThreadedEventLoopGroup(numberOfThreads: System.coreCount)
43
43
lifecycle.registerShutdown(
44
-
name: "eventLoopGroup",
44
+
label: "eventLoopGroup",
45
45
eventLoopGroup.syncShutdownGracefully
46
46
)
47
47
@@ -53,7 +53,7 @@ lifecycle.registerShutdown(
53
53
// and `shutdown` function to be called on shutdown
54
54
let migrator =DatabaseMigrator()
55
55
lifecycle.register(
56
-
name: "migrator",
56
+
label: "migrator",
57
57
start: .async(migrator.migrate),
58
58
shutdown: .async(migrator.shutdown)
59
59
)
@@ -62,7 +62,7 @@ lifecycle.register(
62
62
//
63
63
// start handlers passed using the `register` function
64
64
// will be called in the order they were registered in
65
-
lifecycle.start() { error in
65
+
lifecycle.start { error in
66
66
// start completion handler.
67
67
// if a startup error occurred you can capture it here
68
68
iflet error = error {
@@ -118,7 +118,7 @@ where `Lifecycle.Handler` is a container for an asynchronous closure defined as
118
118
```swift
119
119
let foo =...
120
120
lifecycle.register(
121
-
name: "foo",
121
+
label: "foo",
122
122
start: .async(foo.asyncStart),
123
123
shutdown: .async(foo.asyncShutdown)
124
124
)
@@ -129,23 +129,23 @@ or, just shutdown:
129
129
```swift
130
130
let foo =...
131
131
lifecycle.registerShutdown(
132
-
name: "foo",
132
+
label: "foo",
133
133
.async(foo.asyncShutdown)
134
134
)
135
135
```
136
136
137
137
138
-
you can also register a collection of `LifecycleItem`s (less typical) using:
138
+
you can also register a collection of `Lifecycle.Task`s (less typical) using:
139
139
140
140
```swift
141
-
funcregister(_items: [LifecycleItem])
141
+
funcregister(_tasks: [Lifecycle.Task])
142
142
143
-
internalfuncregister(_items: LifecycleItem...)
143
+
funcregister(_tasks: Lifecycle.Task...)
144
144
```
145
145
146
146
### Configuration
147
147
148
-
`ServiceLifecycle`constructor takes optional `Lifecycle.Configuration` to further refine the `ServiceLifecycle` behavior:
148
+
`ServiceLifecycle`initializer takes optional `ServiceLifecycle.Configuration` to further refine the `ServiceLifecycle` behavior:
149
149
150
150
*`callbackQueue`: Defines the `DispatchQueue` on which startup and shutdown handlers are executed. By default, `DispatchQueue.global` is used.
151
151
@@ -162,7 +162,7 @@ Start handlers passed using the `register` function will be called in the order
162
162
If a startup error occurred, it will be logged and the startup sequence will halt on the first error, and bubble it up to the provided completion handler.
Typical use of the library is to call on `wait` after calling `start`.
177
177
178
178
```swift
179
-
lifecycle.start() { error in
179
+
lifecycle.start { error in
180
180
...
181
181
}
182
182
lifecycle.wait() // <-- blocks the thread
@@ -203,16 +203,16 @@ startup order will be 1, 2, 3 and shutdown order will be 3, 2, 1.
203
203
204
204
If a shutdown error occurred, it will be logged and the shutdown sequence will *continue* to the next item, and attempt to shut it down until all registered items that have been started are shut down.
205
205
206
-
In more complex cases, when signal trappingbased shutdown is not appropriate, you may pass `nil` as the `shutdownSignal` configuration, and call `shutdown` manually when appropriate. This is designed to be a rarely used pressure valve.
206
+
In more complex cases, when `Signal`-trapping-based shutdown is not appropriate, you may pass `nil` as the `shutdownSignal` configuration, and call `shutdown` manually when appropriate. This is designed to be a rarely used pressure valve.
207
207
208
-
`shutdown` is an asynchronous operation. Errors will be logged and bubble it up to the provided completion handler.
208
+
`shutdown` is an asynchronous operation. Errors will be logged and bubbled up to the provided completion handler.
209
209
210
210
### Complex Systems and Nesting of Subsystems
211
211
212
212
In larger Applications (Services) `ComponentLifecycle` can be used to manage the lifecycle of subsystems, such that `ServiceLifecycle` can start and shutdown `ComponentLifecycle`s.
213
213
214
214
In fact, since `ComponentLifecycle` conforms to `Lifecycle.Task`,
215
-
it can start and stop other `ComponentLifecycles`, forming a tree. E.g.:
215
+
it can start and stop other `ComponentLifecycle`s, forming a tree. E.g.:
216
216
217
217
```swift
218
218
structSubSystem {
@@ -249,12 +249,12 @@ lifecycle.wait()
249
249
250
250
SwiftServiceBootstrap comes with a compatibility module designed to make managing SwiftNIO based resources easy.
251
251
252
-
Once you import `LifecycleNIOCompat` module, `Lifecycle.Handler` gains a static helpers named `eventLoopFuture` designed to help simplify the registration call to:
252
+
Once you import `LifecycleNIOCompat` module, `Lifecycle.Handler` gains a static helper named `eventLoopFuture` designed to help simplify the registration call to:
0 commit comments