Commit Graph
10 Commits
Author SHA1 Message Date
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 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
2020-10-26 16:12:50 -07:00
Fabian Fett 8f61d72551 Add some NIO sugar to ServiceLifecycle.start() (#72) 2020-09-01 10:25:02 -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
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 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
tomer doron 77c2610f87 rename project to SwiftServiceBootstrap (#36)
motivation: better name

changes:
* update license headers
* update sanity checks
2020-04-09 21:23:49 -07:00
tomer doron a22bf0b3be refactor towards 1.0 (#34)
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
2020-04-09 21:15:22 -07:00
tomer doron 070734a734 rename module (#12)
motivation: adjust module name to avoid ambiguity between module and main type

changes: rename Lifecycle to ServiceLauncher
2020-03-31 20:08:32 -07:00
tomer doron 46a98e2852 refactor "append" api (#3)
motivation: simplify registering items based on closures

changes:
* rename append to register
* introduce a Handler object that is an enum of sorts for types of startup and shutdown handler signature we support
* refactor tests to use the new code
2020-03-23 11:35:55 -07:00