Skip to content

Commit

Permalink
Initialize new provider and shutdown old provider synchronously in in…
Browse files Browse the repository at this point in the history
…itNewAndShutdownOld
  • Loading branch information
Selamba committed Dec 13, 2023
1 parent dbb68e3 commit 25890d0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions openfeature/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,11 @@ func (api *evaluationAPI) forTransaction(clientName string) (FeatureProvider, []
}

// initNewAndShutdownOld is a helper to initialise new FeatureProvider and shutdown the old FeatureProvider.
// Operations happen concurrently.
// Operations happen NOT concurrently.
func (api *evaluationAPI) initNewAndShutdownOld(newProvider FeatureProvider, oldProvider FeatureProvider) {
v, ok := newProvider.(StateHandler)
if ok && v.Status() == NotReadyState {
go func(provider FeatureProvider, stateHandler StateHandler, evalCtx EvaluationContext, eventChan chan eventPayload) {
func(provider FeatureProvider, stateHandler StateHandler, evalCtx EvaluationContext, eventChan chan eventPayload) {
err := stateHandler.Init(evalCtx)
// emit ready/error event once initialization is complete
if err != nil {
Expand Down Expand Up @@ -206,7 +206,7 @@ func (api *evaluationAPI) initNewAndShutdownOld(newProvider FeatureProvider, old
return
}

go func(forShutdown StateHandler) {
func(forShutdown StateHandler) {
forShutdown.Shutdown()
}(v)
}
Expand Down

0 comments on commit 25890d0

Please sign in to comment.