Skip to content

Commit

Permalink
fix: various clarifications (#193)
Browse files Browse the repository at this point in the history
* loosen shutdown requirements to support things like go ctx
* clarify how to handle init/shutdown of providers bound to multiple names
* clarify that authors can await the READY event during init

Signed-off-by: Todd Baert <[email protected]>
  • Loading branch information
toddbaert authored Jun 2, 2023
1 parent 975a908 commit 77e0b9c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
4 changes: 2 additions & 2 deletions specification.json
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@
{
"id": "Requirement 1.6.1",
"machine_id": "requirement_1_6_1",
"content": "The API MUST define a `shutdown` function which, when called, must call the respective `shutdown` function on the active provider.",
"content": "The API MUST define a mechanism to propagate a shutdown request to active providers.",
"RFC 2119 keyword": "MUST",
"children": []
},
Expand Down Expand Up @@ -386,7 +386,7 @@
{
"id": "Requirement 2.5.1",
"machine_id": "requirement_2_5_1",
"content": "The provider MAY define a `shutdown` function to perform whatever cleanup is necessary for the implementation.",
"content": "The provider MAY define a mechanism to gracefully shutdown and dispose of resources.",
"RFC 2119 keyword": "MAY",
"children": []
},
Expand Down
13 changes: 8 additions & 5 deletions specification/sections/01-flag-evaluation.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,18 @@ See [provider](./02-providers.md) for details.

> The `provider mutator` function **MUST** invoke the `initialize` function on the newly registered provider before using it to resolve flag values.
Application authors can await the newly set `provider's` readiness using the `PROVIDER_READY` event.
Provider instances which are already active (because they have been bound to other `names` or otherwise) need not be initialized again.
The `provider's` readiness can state can be determined from its `status` member/accessor.

See [provider initialization](./02-providers.md#24-initialization).
See [event handlers and initialization](./05-events.md#event-handlers-and-initialization), [provider initialization](./02-providers.md#24-initialization).

#### Requirement 1.1.2.3

> The `provider mutator` function **MUST** invoke the `shutdown` function on the previously registered provider once it's no longer being used to resolve flag values.
Setting a new provider means the previous provider is no longer in use, and should therefore be disposed of using its `shutdown` function.
When a provider is no longer in use, it should be disposed of using its `shutdown` mechanism.
Provider instances which are bound to multiple names won't be shut down until the last binding is removed.

see: [shutdown](./02-providers.md#25-shutdown), [setting a provider](#setting-a-provider)

Expand Down Expand Up @@ -274,9 +277,9 @@ See [hooks](./04-hooks.md) for details.

#### Requirement 1.6.1

> The API **MUST** define a `shutdown` function which, when called, must call the respective `shutdown` function on the active provider.
> The API **MUST** define a mechanism to propagate a shutdown request to active providers.
The precise name of this function is not prescribed by this specification, but should be defined be the SDK.
Relevant language idioms should be considered when choosing the name for this function, in accordance with the resource-disposal semantics of the language in question.
The global API object might expose a `shutdown` function, which will call the respective `shutdown` function on the registered providers.
Alternatively, implementations might leverage language idioms such as auto-disposable interfaces or some means of cancellation signal propagation to allow for graceful shutdown.

see: [`shutdown`](./02-providers.md#25-shutdown)
8 changes: 4 additions & 4 deletions specification/sections/02-providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@ see: [error codes](https://openfeature.dev/specification/types#error-code)

#### Requirement 2.5.1

> The provider **MAY** define a `shutdown` function to perform whatever cleanup is necessary for the implementation.
> The provider **MAY** define a mechanism to gracefully shutdown and dispose of resources.
```java
// MyProvider implementation of the dispose function defined in Provider
class MyProvider implements Provider, AutoDisposable {
Expand All @@ -249,6 +250,5 @@ class MyProvider implements Provider, AutoDisposable {
```

Providers may maintain remote connections, timers, threads or other constructs that need to be appropriately disposed of.
Provider authors may implement the `shutdown` function to perform relevant clean-up actions.
The precise name of this function is not prescribed by this specification, but should be defined be the SDK.
Relevant language idioms should be considered when choosing the name for this function, in accordance with the resource-disposal semantics of the language in question.
Provider authors may implement a `shutdown` function to perform relevant clean-up actions.
Alternatively, implementations might leverage language idioms such as auto-disposable interfaces or some means of cancellation signal propagation to allow for graceful shutdown.

0 comments on commit 77e0b9c

Please sign in to comment.