Commit Graph
77 Commits
Author SHA1 Message Date
Konrad `ktoso` Malawski 4755d7fc1e Fix availability annotations to include platforms 2022-06-22 17:38:49 +09:00
tomer doron 2744df51f9 unless shutdownIfNotStarted is set to true, dont shutdown items that failed to start (#107)
motivation: improve confusing behavior

changes:
* change startTask to return an array of started tasks instead of an index
* only shutdown successfully started tasks or ones that have explicitly set shutdownIfNotStarted to true
* add and adjust tests
1.0.0-alpha.8
2021-09-03 23:17:55 -07:00
tomer doron c825a58490 shutdown any task that have shutdownIfNotStarted set to true when shutting down a never-started-lifecycle (#109)
motivation: more reliable shutdown in edge cases where lifecycle never gets started

changes: when shutting down an idle lifecycle, try to shutdown any tasks that have shutdownIfNotStarted set to true
2021-09-02 08:48:04 -07:00
tomer doron f6c02f7b46 only install jazzy on latest ubuntu versions (#108)
motivation: jazzy no longer works on older version of ubuntu as ruby is too old

changes: update docker to only install jazzy on latest ubuntu versions
2021-09-01 22:45:00 -07:00
tomer doron 66fb9c089b fix repeated shutdown issue on linux (#104)
motivation: repeatedly calling shutdown in linux was broken due to multiple calls to singal() which work on darwin but not linux

changes:
* conditionalize the call to signal to once per process
* add test
2021-08-19 17:23:03 -07:00
tomer doron b00bee04fd add 5.5 ci (#105)
motivation: test with 5.5

changes: add 5.5. docker-compose and pin jazzy version
2021-08-19 14:45:13 -07:00
tomer doron 9a23b01e25 adopt SSWG security guidelines (#101)
* adopt SSWG security guidelines

add SECURITY.md detailing the security process

* Update README.md
2021-06-21 11:24:24 +09:00
tomer doron 84d2bc37d7 adjust to updated concurrency API (#102) 2021-06-09 19:00:28 -07:00
tomer doron 7f70674c22 add handlers that support async functions (#99)
motivation: async/await is coming in 5.5, take first steps to support it

changes:
* introduce handler initializers that takes async functions (@escaping () async throws -> Void, @escaping () async throws -> State)
* add tests
2021-05-12 21:41:15 -07:00
tomer doron ad8631e430 update 5.4 to release docker image (#98)
motivation: 5.4 is out!

changes: use release docker images instead of nightly
2021-05-06 17:57:32 -07:00
tomer doron 727db6c591 Update docker-compose.2004.main.yaml (#97)
motivation: fix nightly docker setup

changes: fix typo
2021-05-06 17:42:24 -07:00
Moritz Lang 103c143d52 Remove [Lifecycle] prefix from log messages (#95)
Motivation:

Since Swift Log 1.3.0, log handlers can include the source of a particular message,
rendering the [Lifecycle] prefix unnecessary.

Modifications:

Removed the [Lifecycle] prefix from all log messages by removing the underlying
log helper and calling out to the Logger itself.

Result:

Log messages written by a log handler which includes the location wont log "Lifecycle" twice.
2021-05-04 11:58:13 +09:00
tomer doron 4714c3cdfa add lifecycle metrics (#93)
motivation: startup/shutdown metrics are important for real-life services, for example spike in start metrics indicates a crash-loop

changes:
* add start and shutdown counters to ComponentLifecycle
* add start and shutdown timers to report duration of startup and shutdown operations
1.0.0-alpha.7
2021-03-18 11:39:26 -07:00
tomer doron 5577147e4e make the underlying component lifecycle private again (#91)
* make the underlying component lifecycle private again

motivation: there is no need to explose the underlying component lifecycle, since there are better composition solutions

changets: make ServiceLifecycle::underlying private (again)

* fixup
2021-03-18 09:12:50 +09:00
Fabian Fett e5e078d534 Import Atomics @_implementationOnly (#89) 2021-03-17 13:52:57 -07:00
tomer doron 8b5c377ae3 Revert "Install shutdown signal hooks as LifecycleTask (#88)" (#90)
motivation: start handlers should not actually be part of the initialization process, as it breaks composition between ServiceLifecycles

changes: This reverts commit dce53aa6f2.
2021-03-17 12:54:27 -07:00
Joakim Hassila dce53aa6f2 Install shutdown signal hooks as LifecycleTask (#88)
Motivation:

Small code cleanup, reusing LifecycleTask as the shutdown hooks are
to be installed just at the beginning of that chain of events anyway.

Modifications:

Moved signal handler installation to LifecycleTask instead of direct calls.

Result:

Slightly simpler code.
2021-03-16 12:18:57 -07:00
tomer doron e6b78a807b add support for stateful handler (#84)
motivation: allow lifecycle handlers to have the library manage the state for them so they do not need to do that manually

changes:
* introduce LifecycleStartHandler and LifecycleShutdownHandler which can handle state on behalf of the lifecycle item
* add registerStateful function to regsiter stateful handlers
* add tests
2021-03-13 11:29:28 -08:00
tomer doron faa9f17905 expose the underlying lifecycle for composition reasons (#70)
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)
2021-03-13 11:20:42 -08:00
Joakim Hassila ac8ba89a91 Add support for HUP, USR1, USR2 signals (#86)
Motivation:

Adding support for capturing HUP too in addition to USR1/USR2.

Modifications:

* Added HUP signal, added descriptive strings for new signals.
* Optionally allow to let signal handler run multiple times, useful for USR signals

Result:
HUP and USR signals available.
2021-03-12 20:42:54 -08:00
Joakim Hassila 91c9f1ea55 Updated target dependency example (#85)
Updated the dependency to use .product as instructed by SPM when trying to follow the instructions.
2021-03-12 12:11:50 -08:00
tomer doron 272d1f589f expose shutdownIfNotStarted argument on regsiter (#83)
motivation: in some cases, users want to force shutdown even if start never called, for example if the library asserts for shutdown regardless of start

changes: expose shutdownIfNotStarted on regsiter function
2021-03-10 17:42:01 -08:00
tomer doron 1e2fa84316 add 5.4 and nightly ci jobs (#82)
motivation: prepare for 5.4 and test against nightlies

changes:
* add docker compose setup for 5.4 and nightly testing
2021-03-11 10:34:53 +09:00
tomer doron 19e0ab6b43 use welcoming language (#79) 2021-02-09 11:03:05 -08:00
tomer doron a7356e142b add semantics for stopping tasks that have no start handler (#77)
motivation: address shutdown for tasks which allocate resources on construction. before this change, only tasks that have been started are shutdown, this creates an issue when the resources are allocated on construction since the item may not get started at all (for example due to error in earlier task) and thus will never be shutdown and the resources will leak.

changes: add sematics to request shutdown even if not started, and assume this sematics when registering with start: .none or with registerShutdown
1.0.0-alpha.6
2020-10-26 16:12:50 -07:00
tomer doron a7932002e9 remove symbolicate-linux-fatal from Docker (#76)
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
2020-10-08 09:14:17 +09:00
tomer doron 3a02d48c95 abstract registration functions into a protocol (#75)
motivation: allow frameworks that want to expose the lifecycle so that their downstream dependencies could register additional items

changes: abstract registration functions into a protocol and conform ComponentLifecycle and ServiceLifecycle to it
1.0.0-alpha.5
2020-09-26 16:42:20 -07:00
tomer doron adb39391ff Swift 5.3 was released, use if for CI (#74)
motivation: Swift 5.3 was released, use if for CI

changes: update docker setup to use the release version of 5.3
2020-09-20 19:00:40 -07:00
adfec6ae94 API docs cleanup and other minor fixes (#73)
motivation: better API docs and usability

changes:
* allow customization of ServiceLifecycle label
* adjust APi docs
* fix tests on macOS (availability)

Co-authored-by: Yim Lee <yim_lee@apple.com>
Co-authored-by: Konrad `ktoso` Malawski <konrad.malawski@project13.pl>
2020-09-01 14:43:57 -07:00
Fabian Fettandtomer doron c0c22246a3 Remove unused macOS(.v10_12) platform requirement (#71)
Co-authored-by: tomer doron <tomerd@apple.com>
2020-09-01 10:28:59 -07:00
Fabian Fett 8f61d72551 Add some NIO sugar to ServiceLifecycle.start() (#72) 2020-09-01 10:25:02 -07:00
tomer doron c8e99520d7 setup shutdown hooks on ServiceLifecycle::startAndWait (#69)
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)
2020-08-08 20:27:20 -07:00
tomer doron 24330545bd Update CONTRIBUTING.md (#67)
motivation: move from `master` to `main`, also make link less fragile

changes: make link relative
2020-08-05 10:49:47 +09:00
Darrell b450a7dd15 Updated README.md to include logger configuration option (#63)
The README.md only listed 3 of the 4 Configuration options and did not mention the logging option.
Added logging option to the configuration discussion.
Placed it first, which is the same as the argument order for ServiceLifecycle.Configuration.
2020-07-20 14:01:12 -07:00
Florian ReinhartandKonrad `ktoso` Malawski dda1fc59a6 Add lifecycle handler to cancel repeated tasks (#60)
* Add lifecycle handler to cancel repeated tasks

* =formatting

Co-authored-by: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
2020-07-20 22:34:53 +09:00
Florian Reinhart 2783134d86 Add commit message template (#62) 2020-07-20 22:22:04 +09:00
Alessio Buratti eb685b6fa1 Update ServiceLifecycle.Configuration comments (#58)
It seems to me that the comments of shutdownSignal and installBacktrace were inverted, I apologize in advance if I misunderstood something.
2020-07-17 11:20:46 -07:00
YR Chen 5ad999203c Allow zero-task startup (#55)
* Allow zero-task startup

* Add test for zero-task

* Fix Linux build and improve consistency

* Fix sanity
2020-07-17 12:28:22 +09:00
YR Chenandtomer doron 945d681aee Fix typo (#56)
Co-authored-by: tomer doron <tomerd@apple.com>
2020-07-16 18:07:36 -07:00
Konrad `ktoso` Malawski 975d8ee1d2 +readme add more info about the sanity script to the contributing readme (#57) 2020-07-16 18:03:01 -07:00
Alexander Cyon 6742fc4ce8 fix typo (#48) 2020-07-16 07:41:53 -07:00
Alexander Cyonandtomer doron 0c9056b586 Tweak README. (#52)
Co-authored-by: tomer doron <tomerd@apple.com>
2020-07-16 07:37:11 -07:00
Alexander Cyon 7afb846cac Give markdown rendering of README inside Xcode (#51) 2020-07-16 07:29:48 -07:00
tomer doron 7a7e0e6c97 update dependency version string 2020-07-15 14:58:38 -07:00
tomer doron daef88b82a prepare to open source (#47)
motivation: cleanup naming and collatoral in preperation to open sourcing the library

changes:
* rename "bootstrap" to "lifecycle"
* contributors list
2020-07-15 14:57:44 -07:00
tomer doron b5ead647f9 remove closure variants to reduce API confusion (#46)
motivation:

API now includes closure based variants, saving the need to wrap them in .sync
Users have complained that these overloads add confusion, and probably not worth the additional API surface area

changes:
* remove the sync closure API overloads
* update readme, examples and tests
1.0.0-alpha.4
2020-07-14 10:01:19 -07:00
tomer doron e1ec2b708b Update README.md (#43)
motivation: clearer readme

changes: SwiftServiceLifecycle -> Swift Service Lifecycle
2020-07-07 18:34:46 -07:00
Konrad `ktoso` Malawski 2891ee74b6 Slightly nicer string description for Signal (#42)
* Slightly nicer string description for Signal
* compat with swift before 5.3
2020-06-26 08:56:58 -07:00
tomer doron 6dde12ac74 update readme to reflect api changes (#41) 1.0.0-alpha.3 2020-05-27 19:38:44 -07:00
tomer doron 19c52240e6 update api to remove Lifecycle psuedo namespace (#40)
motivation: address api feedback, do not clash module and type names

changes:
* remove top level Lifecycle psuedo namespace (enum)
* rename Lifecycle.Task to LifecyclTask
* rename Lifecycle.Handler to LifecycleHandler
2020-05-27 19:20:26 -07:00