Skip to content

Commit

Permalink
feat: handle consolidated configuration change event
Browse files Browse the repository at this point in the history
Signed-off-by: Skye Gill <[email protected]>
  • Loading branch information
skyerus committed Jan 3, 2023
1 parent b0f7362 commit 7217c3c
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions providers/flagd/pkg/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,22 +501,24 @@ func (p *Provider) handleConfigurationChangeEvent(ctx context.Context, event *sc
return errors.New("no data in event")
}

flagKeyVal, ok := event.Data.AsMap()["flagKey"]
flagsVal, ok := event.Data.AsMap()["flags"]
if !ok {
return errors.New("no flagKey field in event data")
return errors.New("no flags field in event data")
}

flagKey, ok := flagKeyVal.(string)
flags, ok := flagsVal.(map[string]interface{})
if !ok {
return errors.New("flagKey is not a string")
return errors.New("flags isn't a map")
}

// TODO: consider sending the flag type in the configuration change event
p.booleanCache.Remove(flagKey)
p.intCache.Remove(flagKey)
p.floatCache.Remove(flagKey)
p.interfaceCache.Remove(flagKey)
p.stringCache.Remove(flagKey)
for flagKey, _ := range flags {
// TODO: consider sending the flag type in the configuration change event
p.booleanCache.Remove(flagKey)
p.intCache.Remove(flagKey)
p.floatCache.Remove(flagKey)
p.interfaceCache.Remove(flagKey)
p.stringCache.Remove(flagKey)
}

return nil
}
Expand Down

0 comments on commit 7217c3c

Please sign in to comment.