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
Copy file name to clipboardExpand all lines: README.md
+16-15
Original file line number
Diff line number
Diff line change
@@ -1,16 +1,16 @@
1
1
# Swift Service Lifecycle
2
2
3
-
Swift Service Lifecycle provides a basic mechanism to cleanly start up and shut down the application, freeing resources inorder before exiting.
3
+
Swift Service Lifecycle provides a basic mechanism to cleanly start up and shut down an application, freeing resources in-order before exiting.
4
4
It also provides a `Signal`-based shutdown hook, to shut down on signals like `TERM` or `INT`.
5
5
6
6
Swift Service Lifecycle was designed with the idea that every application has some startup and shutdown workflow-like-logic which is often sensitive to failure and hard to get right.
7
-
The library codes this common need in a safe and reusable way that is non-framework specific, and designed to be integrated with any server framework or directly in an application. Furthermore, it integrates natively with Structured Concurrency.
7
+
The library encodes this common need in a safe and reusable way that is non-framework specific, and designed to be integrated with any server framework or directly in an application. Furthermore, it integrates natively with Structured Concurrency.
8
8
9
9
This is the beginning of a community-driven open-source project actively seeking [contributions](CONTRIBUTING.md), be it code, documentation, or ideas. What Swift Service Lifecycle provides today is covered in the [API docs](https://swiftpackageindex.com/swift-server/swift-service-lifecycle/main/documentation/servicelifecycle), but it will continue to evolve with community input.
10
10
11
11
## Getting started
12
12
13
-
If you have a server-side Swift application or a cross-platform (e.g. Linux, macOS) application, and you would like to manage its startup and shutdown lifecycle, Swift Service Lifecycle is a great idea. Below you will find all you need to know to get started.
13
+
Swift Service Lifecycle should be used if you have a server-side Swift application or a cross-platform (e.g. Linux, macOS) application, and you would like to manage its startup and shutdown lifecycle. Below you will find all you need to know to get started.
14
14
15
15
### Adding the dependency
16
16
@@ -20,7 +20,7 @@ To add a dependency on the package, declare it in your `Package.swift`:
@@ -29,7 +29,7 @@ and to your application target, add `ServiceLifecycle` to your dependencies:
29
29
Example `Package.swift` file with `ServiceLifecycle` as a dependency:
30
30
31
31
```swift
32
-
// swift-tools-version:5.9
32
+
// swift-tools-version:6.0
33
33
importPackageDescription
34
34
35
35
letpackage=Package(
@@ -50,16 +50,17 @@ let package = Package(
50
50
51
51
### Using ServiceLifecycle
52
52
53
-
Below is a short usage example however you can find detailed documentation on how to use ServiceLifecycle over [here](https://swiftpackageindex.com/swift-server/swift-service-lifecycle/main/documentation/servicelifecycle).
54
-
55
-
ServiceLifecycle consists of two main building blocks. First, the `Service` protocol and secondly
56
-
the `ServiceGroup`. As a library or application developer you should model your long-running work
57
-
as services that implement the `Service` protocol. The protocol only requires a single `func run() async throws`
58
-
method to be implemented.
59
-
Afterwards, in your application you can use the `ServiceGroup` to orchestrate multiple services.
60
-
The group will spawn a child task for each service and call the respective `run` method in the child task.
61
-
Furthermore, the group will setup signal listeners for the configured signals and trigger a graceful shutdown
62
-
on each service.
53
+
You can find a short usage example below. You can find more detailed
0 commit comments