Skip to content

Commit 8212c30

Browse files
committed
fixup: reset state, run on all providers
Signed-off-by: Todd Baert <[email protected]>
1 parent 5cda5b1 commit 8212c30

File tree

3 files changed

+27
-12
lines changed

3 files changed

+27
-12
lines changed

specification.json

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,15 +283,15 @@
283283
{
284284
"id": "Requirement 1.6.1",
285285
"machine_id": "requirement_1_6_1",
286-
"content": "The API MUST define a function to propagate a shutdown request to active providers.",
286+
"content": "The API MUST define a function to propagate a shutdown request to all providers.",
287287
"RFC 2119 keyword": "MUST",
288288
"children": []
289289
},
290290
{
291291
"id": "Requirement 1.6.2",
292292
"machine_id": "requirement_1_6_2",
293-
"content": "The API's `shutdown` function MUST NOT call shutdown on providers which are in state `NOT_READY`.",
294-
"RFC 2119 keyword": "MUST NOT",
293+
"content": "The API's `shutdown` function MUST reset all state of the API, removing all hooks, event handlers, and providers.",
294+
"RFC 2119 keyword": "MUST",
295295
"children": []
296296
},
297297
{
@@ -511,7 +511,14 @@
511511
{
512512
"id": "Requirement 2.5.2",
513513
"machine_id": "requirement_2_5_2",
514-
"content": "After a provider's shutdown function has terminated, the provider SHOULD revert to its uninitialized state.",
514+
"content": "After a provider's `shutdown` function has terminated, the provider SHOULD revert to its uninitialized state.",
515+
"RFC 2119 keyword": "SHOULD",
516+
"children": []
517+
},
518+
{
519+
"id": "Requirement 2.5.3",
520+
"machine_id": "requirement_2_5_3",
521+
"content": "A Provider's `shutdown` function SHOULD be idempotent.",
515522
"RFC 2119 keyword": "SHOULD",
516523
"children": []
517524
},

specification/sections/01-flag-evaluation.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -401,21 +401,20 @@ See [hooks](./04-hooks.md) for details.
401401

402402
#### Requirement 1.6.1
403403

404-
> The API **MUST** define a function to propagate a shutdown request to active providers.
404+
> The API **MUST** define a function to propagate a shutdown request to all providers.
405405
406-
The global API object might expose a `shutdown` function, which will call the respective `shutdown` function on the active providers.
406+
The global API object defines a `shutdown` function, which will call the respective `shutdown` function on the active providers.
407407
Alternatively, implementations might leverage language idioms such as auto-disposable interfaces or some means of cancellation signal propagation to allow for graceful shutdown.
408+
This shutdown function unconditionally calls the shutdown function on all registered providers, regardless of their state.
408409

409410
see: [`shutdown`](./02-providers.md#25-shutdown)
410411

411412
#### Requirement 1.6.2
412413

413-
> The API's `shutdown` function **MUST NOT** call shutdown on providers which are in state `NOT_READY`.
414+
> The API's `shutdown` function **MUST** reset all state of the API, removing all hooks, event handlers, and providers.
414415
415-
With respect to the lifecycle of a given active provider, the global API object's `shutdown` function should be idempotent; multiple calls to `shutdown` should result in only a single execution of the provider's `shutdown` function.
416-
Implementations should take care to await or cancel the initialization of providers if `shutdown` is called while providers are still being initialized, and have yet to transition to `READY` or some other state.
417-
418-
see: [`shutdown`](./02-providers.md#25-shutdown)
416+
After shutting down all providers, the `shutdown` function resets the state of the API.
417+
This is especially useful for testing purposes to restore the API to a known state.
419418

420419
### 1.7. Provider Lifecycle Management
421420

specification/sections/02-providers.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,20 @@ class MyProvider implements Provider, AutoDisposable {
225225

226226
#### Requirement 2.5.2
227227

228-
> After a provider's shutdown function has terminated, the provider **SHOULD** revert to its uninitialized state.
228+
> After a provider's `shutdown` function has terminated, the provider **SHOULD** revert to its uninitialized state.
229229
230230
If a provider requires initialization, once it's shut down, it must transition to its uninitialized state.
231231
Some providers may allow reinitialization from this state.
232232
Providers not requiring initialization are assumed to be ready at all times.
233+
Providers in the process of initializing abort initialization if shutdown is called while they are still starting up.
234+
235+
see: [initialization](#24-initialization)
236+
237+
#### Requirement 2.5.3
238+
239+
> A Provider's `shutdown` function **SHOULD** be idempotent.
240+
241+
If a provider's `shutdown` function has been called, subsequent calls (without an intervening call to `initialize`) should have no effect.
233242

234243
see: [initialization](#24-initialization)
235244

0 commit comments

Comments
 (0)