Skip to content

Commit 49d9472

Browse files
authored
Update README (#38)
Motivation: README still contains references to old code Modifications: Update README to match recent code adjustments Result: Correct code snippets in README
1 parent 0e2d952 commit 49d9472

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

README.md

+17-17
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ let lifecycle = ServiceLifecycle()
4141
// and passing its `syncShutdownGracefully` function to be called on shutdown
4242
let eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: System.coreCount)
4343
lifecycle.registerShutdown(
44-
name: "eventLoopGroup",
44+
label: "eventLoopGroup",
4545
eventLoopGroup.syncShutdownGracefully
4646
)
4747

@@ -53,7 +53,7 @@ lifecycle.registerShutdown(
5353
// and `shutdown` function to be called on shutdown
5454
let migrator = DatabaseMigrator()
5555
lifecycle.register(
56-
name: "migrator",
56+
label: "migrator",
5757
start: .async(migrator.migrate),
5858
shutdown: .async(migrator.shutdown)
5959
)
@@ -62,7 +62,7 @@ lifecycle.register(
6262
//
6363
// start handlers passed using the `register` function
6464
// will be called in the order they were registered in
65-
lifecycle.start() { error in
65+
lifecycle.start { error in
6666
// start completion handler.
6767
// if a startup error occurred you can capture it here
6868
if let error = error {
@@ -118,7 +118,7 @@ where `Lifecycle.Handler` is a container for an asynchronous closure defined as
118118
```swift
119119
let foo = ...
120120
lifecycle.register(
121-
name: "foo",
121+
label: "foo",
122122
start: .async(foo.asyncStart),
123123
shutdown: .async(foo.asyncShutdown)
124124
)
@@ -129,23 +129,23 @@ or, just shutdown:
129129
```swift
130130
let foo = ...
131131
lifecycle.registerShutdown(
132-
name: "foo",
132+
label: "foo",
133133
.async(foo.asyncShutdown)
134134
)
135135
```
136136

137137

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:
139139

140140
```swift
141-
func register(_ items: [LifecycleItem])
141+
func register(_ tasks: [Lifecycle.Task])
142142

143-
internal func register(_ items: LifecycleItem...)
143+
func register(_ tasks: Lifecycle.Task...)
144144
```
145145

146146
### Configuration
147147

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:
149149

150150
* `callbackQueue`: Defines the `DispatchQueue` on which startup and shutdown handlers are executed. By default, `DispatchQueue.global` is used.
151151

@@ -162,7 +162,7 @@ Start handlers passed using the `register` function will be called in the order
162162
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.
163163

164164
```swift
165-
lifecycle.start() { error in
165+
lifecycle.start { error in
166166
if let error = error {
167167
logger.error("failed starting \(self) ☠️: \(error)")
168168
} else {
@@ -176,7 +176,7 @@ lifecycle.start() { error in
176176
Typical use of the library is to call on `wait` after calling `start`.
177177

178178
```swift
179-
lifecycle.start() { error in
179+
lifecycle.start { error in
180180
...
181181
}
182182
lifecycle.wait() // <-- blocks the thread
@@ -203,16 +203,16 @@ startup order will be 1, 2, 3 and shutdown order will be 3, 2, 1.
203203

204204
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.
205205

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.
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.
207207

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.
209209

210210
### Complex Systems and Nesting of Subsystems
211211

212212
In larger Applications (Services) `ComponentLifecycle` can be used to manage the lifecycle of subsystems, such that `ServiceLifecycle` can start and shutdown `ComponentLifecycle`s.
213213

214214
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.:
216216

217217
```swift
218218
struct SubSystem {
@@ -249,12 +249,12 @@ lifecycle.wait()
249249

250250
SwiftServiceBootstrap comes with a compatibility module designed to make managing SwiftNIO based resources easy.
251251

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:
253253

254254
```swift
255255
let foo = ...
256256
lifecycle.register(
257-
name: "foo",
257+
label: "foo",
258258
start: .eventLoopFuture(foo.start),
259259
shutdown: .eventLoopFuture(foo.shutdown)
260260
)
@@ -265,7 +265,7 @@ or, just shutdown:
265265
```swift
266266
let foo = ...
267267
lifecycle.registerShutdown(
268-
name: "foo",
268+
label: "foo",
269269
.eventLoopFuture(foo.shutdown)
270270
)
271271
```

0 commit comments

Comments
 (0)