* Bump minimum Swift version to 5.7
Motivation:
Now that Swift 5.9 is GM we should update the supported versions and
remove 5.6
Modifications:
* Update `Package.swift`
* Delete the <5.7 docker compose files and make a 5.10 one
* Update the 5.9 docker file to stop using nightlies
Result:
Remove support for Swift 5.6, add 5.10
* Remove '--enable-test-discovery'
To see if it's causing CI build getting stuck
---------
Co-authored-by: Yim Lee <yim_lee@apple.com>
* Overhaul service lifecycle for Structured Concurrency
# Motivation
Since the release of Swift Concurrency the server ecosystem has adopted `async`/`await` in a lot of APIs making the user experience amazing. Another thing that Swift Concurrency introduced is Structured Concurrency which allows to create a task tree that with parent to child relations. Structured Concurrency has many benefits such as automatic cancellation and task local propagation.
The current state of this library predates the introduction of Swift Concurrency and is not inline anymore with how applications are structured that want to leverage Concurrency.
# Modification
This PR overhauls the implementation of service lifecycle completely. The reason for this is that the current implementation is very focused on how NIO based applications work before the introduction of Concurrency. Furthermore, Structured Concurrency is actually replacing part of the current functionality by providing new scoping mechanisms.
The overhauled implementation provides two primitive types. Anew `Service` protocol and a `ServiceRunner`. The former is providing a clear API which services have to conform to so that they can be run by the `ServiceRunner`.
An example usage of the types looks like this
```swift
actor FooService: Service {
func run() async throws {}
func shutdownGracefully() async throws {}
}
actor BarService: Service {
func run() async throws {}
func shutdownGracefully() async throws {}
}
let fooService = FooService()
let barService = BarService()
let runner = ServiceRunner(
services: [fooService, barService],
configuration: .init(),
logger: logger
)
try await runner.run()
```
# Result
We now have a service lifecycle library that integrates nicely with Structured Concurrency. Its value add is that it solves to complex setup of the task group with the signal handling. Furthermore, it provides a currency type `Service` that can be passed to inject services.
* Remove `shutdownGracefully` method and switch to a handler based approach.
* Code review from George
* Add extensions to `TaskGroup` and `ThrowingTaskGroup`
* Remove long running property
* Documentation
* Fix tests
* Ensure ordering of shutdown
* Test
# Motivation
# Modification
# Result
* Introduce ServiceLifecycleTestKit
* Add AsyncCancelOngracefulShutdownSequence
* Tests and docs for graceful shutdown
# Motivation
# Modification
# Result
* Remove unsafe flags
* Add article for application authors
* Add correct licence and notice information for the things we copied from swift-nio
* Code review
* Remove @_unsafeInheritExectuor
* Code review
* Change log levels, rename to withGracefulShutdownHandler and support nested service runner graceful shutdown
* Add public `shutdownGracefully` method to the service runner
* Code review and expose new cancelOnGracefulShutdown method
* Extend graceful shutdown APIs and tolerate running outside of a `ServiceRunner`
* Rename to `ServiceGroup`
* Enable Swift 5.6 support
* Update soundess dockerfile
* Update Readme
* Make 5.6 build work
motivation: prepare for swift 5.8
changes:
* update use of Locks to address NIO warnings
* update docker compose setup to use release version of 5.7
* add docker compose setup for 5.8
* DocC setup
* Fix formatting
* Fix CI for newer Swift versions
* Rename docc directory
* Revert non-docc related changes
* Revert non-docc related changes
* Use version-specific manifest for older Swift versions
motivation: sometimes a task needs to be de-registered since the task was manually shutdown outside the lifecycle scope
changes:
* registration APIs now return a registration key which can be used as a cancellation token
* add API to de-register a task
* refactor state to use a registery instead of array of tasks
* add tests
motivation: application frameworks thae use ServiceLifecycle may need to expose their underlying lifecycle so they can be also composed into larger systems
changes:
* expose ServiceLifecycle::underlying
* make sure backtrace installer is only called once per process
* add swift-atomics dependency (>=5.2 and above)
* add atomic helper (<5.2)
motivation: we are not actually using symbolicate-linux-fatal in any meaningful way in CI and it's pinned to the master branch which has been removed
changes: remove symbolicate-linux-fatal fetching from Docker
motivation: fix startAndWait to work as advertised
changes:
* extract shutdown setup to a func and call it from both start and startAndWait
* add test
* fix api doc
* fixi jazzy xenial issue (fixes ci)
motivation: finalize naming and API towards 1.0
changes:
* rename package to swift-service-boostrap
* rename modules to Lifecycle and LifecycleNIOCompat
* create top level namespace named Lifecycle
* rename LifecycleItem to LifecycleTask, with Lifecycle.Task typealias
* define top-level type called ServiceLifecycle where signal handling and backtraces are handled
* rename Lifecycle to ComponentLifecycle and conform it to Lifecycle.Task so that lifecycles can be nested
* change shutdown to return an error to better conform with Lifecycle.Task api
* improve logging
* improve API docs
* adjust tests