Skip to content

Commit

Permalink
Add composite ConfigStore to combine multiple ConfigStore
Browse files Browse the repository at this point in the history
In some repositories, we used multiple ConfigStores to store feature
flags, for example, in eventing kafka broker, we use the Eventing
core feature flags store and the EKB feature flags store

Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
  • Loading branch information
pierDipi committed Apr 29, 2024
1 parent b69fa27 commit 57cad9e
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion reconciler/configstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ import "context"

// ConfigStore is used to attach the frozen configuration to the context.
type ConfigStore interface {
// ConfigStore is used to attach the frozen configuration to the context.
// ToContext is used to attach the frozen configuration to the context.
ToContext(ctx context.Context) context.Context
}

// ConfigStores is used to combine multiple ConfigStore and attach multiple frozen configurations
// to the context.
type ConfigStores []ConfigStore

// ConfigStores implements ConfigStore interface.
var _ ConfigStore = ConfigStores{}

func (stores ConfigStores) ToContext(ctx context.Context) context.Context {
for _, s := range stores {
ctx = s.ToContext(ctx)
}
return ctx
}

0 comments on commit 57cad9e

Please sign in to comment.