-
Notifications
You must be signed in to change notification settings - Fork 41
Overhaul service lifecycle for Structured Concurrency #130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
531e74a
Overhaul service lifecycle for Structured Concurrency
FranzBusch e748ec5
Remove `shutdownGracefully` method and switch to a handler based appr…
FranzBusch 7350022
Code review from George
FranzBusch 4c51837
Add extensions to `TaskGroup` and `ThrowingTaskGroup`
FranzBusch 97de525
Remove long running property
FranzBusch e1c3013
Documentation
FranzBusch 364e85d
Fix tests
FranzBusch 020fbfa
Ensure ordering of shutdown
FranzBusch d1e717f
Test
FranzBusch 68aaebb
Introduce ServiceLifecycleTestKit
FranzBusch be3e460
Add AsyncCancelOngracefulShutdownSequence
FranzBusch bcfccdf
Tests and docs for graceful shutdown
FranzBusch 8c5c58a
Remove unsafe flags
FranzBusch 590ea1e
Add article for application authors
FranzBusch a530153
Add correct licence and notice information for the things we copied f…
FranzBusch 2e22daa
Code review
FranzBusch 9797c76
Remove @_unsafeInheritExectuor
FranzBusch 35af255
Code review
FranzBusch d7a56c3
Change log levels, rename to withGracefulShutdownHandler and support …
FranzBusch 7cab86b
Add public `shutdownGracefully` method to the service runner
FranzBusch 7e412d6
Code review and expose new cancelOnGracefulShutdown method
FranzBusch b6834b3
Extend graceful shutdown APIs and tolerate running outside of a `Serv…
FranzBusch c9f8424
Rename to `ServiceGroup`
FranzBusch c8d0efb
Enable Swift 5.6 support
FranzBusch 8dfbcdd
Update soundess dockerfile
FranzBusch e82d688
Update Readme
FranzBusch e59ed5c
Make 5.6 build work
FranzBusch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
version: 1 | ||
builder: | ||
configs: | ||
- documentation_targets: [Lifecycle, LifecycleNIOCompat] | ||
- documentation_targets: [ServiceLifecycle, UnixSignals] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,26 @@ | ||
# file options | ||
|
||
--swiftversion 5.0 | ||
--swiftversion 5.7 | ||
--exclude .build | ||
|
||
# format options | ||
|
||
--self insert | ||
--patternlet inline | ||
--ranges nospace | ||
--stripunusedargs unnamed-only | ||
--ifdef no-indent | ||
--extensionacl on-declarations | ||
--disable typeSugar # https://github.com/nicklockwood/SwiftFormat/issues/636 | ||
--disable andOperator | ||
--disable wrapMultilineStatementBraces | ||
--disable enumNamespaces | ||
--disable redundantExtensionACL | ||
--disable redundantReturn | ||
--disable preferKeyPath | ||
--disable sortedSwitchCases | ||
--disable hoistTry | ||
--disable hoistAwait | ||
--disable redundantOptionalBinding | ||
|
||
# rules |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
The ServiceLifecycle Project | ||
=========================== | ||
|
||
Please visit the ServiceLifecycle web site for more information: | ||
|
||
* https://github.com/swift-server/swift-service-lifecycle | ||
|
||
Copyright 2019-2023 The ServiceLifecycle Project | ||
|
||
The ServiceLifecycle Project licenses this file to you under the Apache License, | ||
version 2.0 (the "License"); you may not use this file except in compliance | ||
with the License. You may obtain a copy of the License at: | ||
|
||
https://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
License for the specific language governing permissions and limitations | ||
under the License. | ||
|
||
Also, please refer to each LICENSE.txt file, which is located in | ||
the 'license' directory of the distribution file, for the license terms of the | ||
components that this product depends on. | ||
|
||
--- | ||
|
||
This product contains derivations of the Lock and LockedValueBox implementations from SwiftNIO. | ||
|
||
* LICENSE (Apache License 2.0): | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* HOMEPAGE: | ||
* https://github.com/apple/swift-nio | ||
|
||
--- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
emitting metric on application start and shutdown has been very valuable in real world production services, the canonical example is a monitoring this to detect an a spike in application restart because of crashes
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally I agree. But ServiceLifecycle created the weird situation in the past where ServiceLifecycle depended on a MetricSystem that adopters wanted to setup with ServiceLifecycle. Basically the first use occurred even before the system was actually ready to create Counters. A good example for this are MetricSystems that are sending their data to a server themselves.
Because of this, I'm a big fan of dropping the swift-metrics dependency here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see your point. Maybe the solution is for this library to take an abstract handler that can emit the specific metrics, or even something like a delegate so that the application / service can do the bridging
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this applies anymore and we can safely take the dependency on
swift-metrics
. A potential metric backend should expose itself as aService
with arun()
method. Furthermore, it should handle receiving metrics before therun()
method is called and buffer them.So the setup that I would recommend here is the following
The thing we should discuss is if we want to provide these metrics out of the box or not. A user could just wrap the call to
serviceRunner.run()
inside metric counters.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right. i tend to think we do want to provide these metrics out of the box, same as we provide logging information and depend on swift-log. could be convinced otherwise if there is strong reason not to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following up on this, I would like to get the PR merged without metrics and then add it on top since the PR is getting quite big.