11# ESPLifecycle
22
3- ESPLifecycle is the ESPToolKit lifecycle orchestrator for deterministic init, deinit, and scoped reinit with ESPStartup-like fluent registration .
3+ ESPLifecycle is the ESPToolKit lifecycle orchestrator for deterministic init, deinit, and node-targeted reinit .
44
55## CI / Release / License
66[ ![ CI] ( https://github.com/ESPToolKit/esp-lifecycle/actions/workflows/ci.yml/badge.svg )] ( https://github.com/ESPToolKit/esp-lifecycle/actions/workflows/ci.yml )
@@ -9,12 +9,12 @@ ESPLifecycle is the ESPToolKit lifecycle orchestrator for deterministic init, de
99
1010## Features
1111- Section-based orchestration with dependency validation (` after ` / ` before ` ).
12- - Deterministic ` initialize() ` , ` deinitialize() ` , ` reinitialize*( ) ` .
13- - Scoped deinit/reinit closure with dependency correctness.
12+ - Deterministic ` initialize() ` , ` deinitialize() ` , and partial ` reinitialize(... ) ` .
13+ - Node-name targeted closure with dependency correctness.
1414- Optional parallel waves for init, deinit, and reinit.
1515- Deferred sections with readiness gates.
1616- Snapshot callback + direct ` snapshotJson() ` helper (ArduinoJson V7).
17- - Optional scope listener with 25ms coalescing.
17+ - Optional reload listener with 25ms coalescing and node-name payload mapping .
1818
1919## Installation
2020- PlatformIO: add ` https://github.com/ESPToolKit/esp-lifecycle.git ` to ` lib_deps ` .
@@ -30,7 +30,7 @@ Dependencies:
3030#include < ESPLifecycle.h>
3131```
3232
33- ## Quick Start (ESPStartup-like)
33+ ## Quick Start
3434``` cpp
3535#include < ESPLifecycle.h>
3636#include < ESPWorker.h>
@@ -46,7 +46,6 @@ void setup() {
4646 cfg.enableParallelInit = true;
4747 cfg.enableParallelDeinit = true;
4848 cfg.enableParallelReinit = true;
49- cfg.onReady = []() { Serial.println("ready"); };
5049
5150 lifecycle.configure(cfg);
5251 lifecycle.init({"core", "network"});
@@ -55,9 +54,11 @@ void setup() {
5554 lifecycle.addTo("core", "storage", []() { return true; }, []() { return true; });
5655 lifecycle.addTo("network", "wifi", []() { return true; }, []() { return true; }).after("logger");
5756
58- if (!lifecycle.start()) {
59- Serial.println("lifecycle start failed");
60- }
57+ (void)lifecycle.build();
58+ (void)lifecycle.initialize();
59+
60+ // Reinitialize logger and everything that depends on it.
61+ (void)lifecycle.reinitialize({"logger"});
6162}
6263```
6364
@@ -71,10 +72,10 @@ lifecycle.section("services")
7172 );
7273```
7374
74- ## Scope Semantics
75- - `deinitializeByScopeMask(mask )` expands to target nodes + transitive dependents.
76- - `reinitializeByScopeMask(mask )` expands to target nodes + dependents + required dependencies.
77- - `reinitializeByNodeNames(... )` uses the same reinit closure rule .
75+ ## Node-Name Targeting Semantics
76+ - `deinitialize({"logger"} )` expands to selected nodes + transitive dependents.
77+ - `reinitialize({"logger"} )` expands to selected nodes + dependents + required dependencies.
78+ - `reinitializeAll( )` keeps full-graph behavior .
7879
7980## Snapshot API
8081```cpp
@@ -92,13 +93,15 @@ serializeJson(json, Serial);
9293
9394## Runtime API
9495- ` LifecycleResult build() `
95- - ` bool start() ` / ` void stop() ` compatibility aliases
9696- ` LifecycleResult initialize() `
9797- ` LifecycleResult deinitialize() `
98- - ` LifecycleResult deinitializeByScopeMask(uint32_t scopeMask) `
98+ - ` LifecycleResult deinitialize(std::initializer_list<const char*> nodeNames) `
99+ - ` LifecycleResult deinitialize(const std::vector<const char*>& nodeNames) `
99100- ` LifecycleResult reinitializeAll() `
100- - ` LifecycleResult reinitializeByScopeMask(uint32_t scopeMask) `
101- - ` LifecycleResult reinitializeByNodeNames(const std::vector<const char*>& nodeNames) `
101+ - ` LifecycleResult reinitialize(std::initializer_list<const char*> nodeNames) `
102+ - ` LifecycleResult reinitialize(const std::vector<const char*>& nodeNames) `
103+ - ` bool startReloadListener(ESPEventBus&, uint16_t, std::function<std::vector<const char*>(void*)>) `
104+ - ` void stopReloadListener() `
102105- ` LifecycleSnapshot snapshot() const `
103106- ` JsonDocument snapshotJson() const `
104107
@@ -109,15 +112,14 @@ serializeJson(json, Serial);
109112- ` continueTeardownOnFailure=false ` stops at first teardown failure.
110113- Busy transitions return ` LifecycleErrorCode::Busy ` .
111114
112- ## Migration from ESPStartup
113- - ` start() ` exists as compatibility alias.
114- - ` stop() ` maps to ` deinitialize() ` .
115- - Each node must provide ` init ` and ` teardown ` callbacks.
116- - Parallel config now exists for all phases.
117-
118115## Examples
119116- ` examples/basic-startup `
120117- ` examples/scoped-reload `
118+ - ` examples/dependency-closure ` - demonstrates dependent closure for partial deinit/reinit.
119+ - ` examples/deferred-readiness ` - deferred section gate using readiness callbacks.
120+ - ` examples/parallel-waves ` - parallel init/deinit/reinit wave behavior.
121+ - ` examples/failure-policy ` - rollback and teardown failure policy behavior.
122+ - ` examples/reload-burst ` - listener burst coalescing and deduplicated node-name reloads.
121123
122124## License
123125MIT - see [ LICENSE.md] ( LICENSE.md ) .
0 commit comments