python-sdk icon indicating copy to clipboard operation
python-sdk copied to clipboard

[FEATURE] Make provider interface "stateless", SDK maintains provider state

Open toddbaert opened this issue 1 year ago • 4 comments

Stateless providers

Providers no longer maintain their own state: the state for each provider is maintained in the SDK automatically, and updated according to the success/failures of lifecycle methods (init/shutdown) or events emitted from providers spontaneously.

### Tasks
- [x] [Requirement 1.7.1](https://openfeature.dev/specification/sections/flag-evaluation#requirement-171): The client MUST define a provider status accessor which indicates the readiness of the associated provider, with possible values NOT_READY, READY, STALE, ERROR, or FATAL.
- [x] [Requirement 1.7.3](https://openfeature.dev/specification/sections/flag-evaluation#requirement-173): The client's provider status accessor MUST indicate READY if the initialize function of the associated provider terminates normally.
- [x] [Requirement 1.7.4](https://openfeature.dev/specification/sections/flag-evaluation#requirement-174): The client's provider status accessor MUST indicate ERROR if the initialize function of the associated provider terminates abnormally.
- [x] [Requirement 1.7.5](https://openfeature.dev/specification/sections/flag-evaluation#requirement-175): The client's provider status accessor MUST indicate FATAL if the initialize function of the associated provider terminates abnormally and indicates error code PROVIDER_FATAL.
- [x] [Requirement 1.7.6](https://openfeature.dev/specification/sections/flag-evaluation#requirement-176): The client MUST default, run error hooks, and indicate an error if flag resolution is attempted while the provider is in NOT_READY.
- [x] [Requirement 1.7.7](https://openfeature.dev/specification/sections/flag-evaluation#requirement-177): The client MUST default, run error hooks, and indicate an error if flag resolution is attempted while the provider is in FATAL.
- [x] [Requirement 1.7.8](https://openfeature.dev/specification/sections/flag-evaluation#requirement-178): Implementations SHOULD propagate the error code returned from any provider lifecycle methods.
- [x] [Requirement 5.1.5](https://openfeature.dev/specification/sections/events#requirement-515): PROVIDER_ERROR events SHOULD populate the provider event details's error code field.
- [x] [Requirement 5.3.5](https://openfeature.dev/specification/sections/events#requirement-535): If the provider emits an event, the value of the client's provider status MUST be updated accordingly.

toddbaert avatar Mar 15 '24 15:03 toddbaert

Is everything completed here? Still need any help/contribution?

ChihweiLHBird avatar Feb 02 '25 06:02 ChihweiLHBird

Hey @ChihweiLHBird, I believe everything is now in place and this issue can be closed. I'll try and validate that this week and let you know if I notice anything missing still. Thanks!

beeme1mr avatar Feb 02 '25 22:02 beeme1mr

@beeme1mr just checking, if you successfully validated it? and this ticket can be closed 🙂

gruebel avatar Feb 22 '25 15:02 gruebel

I've checked the SDK and it seems to be compliant. Most of the work was done in this PR. However, there aren't tests that contain the requirement version from the spec. That would be a nice follow up task if @ChihweiLHBird is interested. Basically, the functionality is there but it's difficult to verify when searching the repo for something like 1.7.1.

Here's an example from the JS SDK that has the spec requirement version in the test description.

beeme1mr avatar Feb 24 '25 15:02 beeme1mr