Skip to content

Commit 77e0b9c

Browse files
authored
fix: various clarifications (#193)
* 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]>
1 parent 975a908 commit 77e0b9c

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

specification.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@
230230
{
231231
"id": "Requirement 1.6.1",
232232
"machine_id": "requirement_1_6_1",
233-
"content": "The API MUST define a `shutdown` function which, when called, must call the respective `shutdown` function on the active provider.",
233+
"content": "The API MUST define a mechanism to propagate a shutdown request to active providers.",
234234
"RFC 2119 keyword": "MUST",
235235
"children": []
236236
},
@@ -386,7 +386,7 @@
386386
{
387387
"id": "Requirement 2.5.1",
388388
"machine_id": "requirement_2_5_1",
389-
"content": "The provider MAY define a `shutdown` function to perform whatever cleanup is necessary for the implementation.",
389+
"content": "The provider MAY define a mechanism to gracefully shutdown and dispose of resources.",
390390
"RFC 2119 keyword": "MAY",
391391
"children": []
392392
},

specification/sections/01-flag-evaluation.md

+8-5
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,18 @@ See [provider](./02-providers.md) for details.
3939

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

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

4648
#### Requirement 1.1.2.3
4749

4850
> 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.
4951
50-
Setting a new provider means the previous provider is no longer in use, and should therefore be disposed of using its `shutdown` function.
52+
When a provider is no longer in use, it should be disposed of using its `shutdown` mechanism.
53+
Provider instances which are bound to multiple names won't be shut down until the last binding is removed.
5154

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

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

275278
#### Requirement 1.6.1
276279

277-
> The API **MUST** define a `shutdown` function which, when called, must call the respective `shutdown` function on the active provider.
280+
> The API **MUST** define a mechanism to propagate a shutdown request to active providers.
278281
279-
The precise name of this function is not prescribed by this specification, but should be defined be the SDK.
280-
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.
282+
The global API object might expose a `shutdown` function, which will call the respective `shutdown` function on the registered providers.
283+
Alternatively, implementations might leverage language idioms such as auto-disposable interfaces or some means of cancellation signal propagation to allow for graceful shutdown.
281284

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

specification/sections/02-providers.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,8 @@ see: [error codes](https://openfeature.dev/specification/types#error-code)
236236

237237
#### Requirement 2.5.1
238238

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

251252
Providers may maintain remote connections, timers, threads or other constructs that need to be appropriately disposed of.
252-
Provider authors may implement the `shutdown` function to perform relevant clean-up actions.
253-
The precise name of this function is not prescribed by this specification, but should be defined be the SDK.
254-
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.
253+
Provider authors may implement a `shutdown` function to perform relevant clean-up actions.
254+
Alternatively, implementations might leverage language idioms such as auto-disposable interfaces or some means of cancellation signal propagation to allow for graceful shutdown.

0 commit comments

Comments
 (0)