Skip to content

Implement Initialize/Shutdown on provider registration #449

Closed
@lopitz

Description

@lopitz

I'd like to take over the task to implement initialize and shutdown on a provider switch, like mentioned here.

It currently looks to me pretty straight forward but please let me know, if you find some important points I might miss.

One of them could be exception handling, as this is not mentioned in the spec at all. Hence, I would go with logging only for exceptions to fulfill Requirement 1.4.9.

Another one could be execution time of the calls to the provider. I see 3 options, sync without timeout, sync with timeout and async.

Async

Advantages

  • setter immediately returns
  • allows for long initialization phase (e.g. while startup) to run in parallel w/o impacting start up time

Disadvantages

  • sdk code more complex as sdk needs to track initialization status of handler (esp. if handler is changed again, while the other handler is still initializing)
  • expectation of client code might be to be able to immediately evaluate flags, which is only possible after initialization (see Requirement 1.1.2.2)

Sync

Advantages

  • sdk code very easy

** Disadvantages **

  • clients may expect an immediate return of the provider mutator, as it is just a "setter"
  • "setter" method (provider mutator) potentially takes very long or even doesn't return at all, depending on the provider's initialization
  • in such a case, the application wouldn't work, just because feature flags are not available - which sounds to me like being the opposite of the whole sdk's design

Sync with Timeout

** Advantages**

  • "setter" method (provider mutator) would definitely return in a given timeframe

** Disadvantages **

  • sdk code more complex as timeout needs to be implemented
  • execution of provider mutator can still take very long (depending on the defined timeout)
  • what happens, if the mutator ran into the timeout? client not being informed, as no exception is thrown and hence no evaluation can be done

My initial thoughts were using the simple sync approach, but when writing up, I'd rather go with the async method as it allows for a "very long" initialization of the provider w/o impacting the client code.

cc @open-feature/sdk-java-approvers @open-feature/sdk-java-maintainers

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions