Skip to content

Commit

Permalink
expose Client for mocking
Browse files Browse the repository at this point in the history
  • Loading branch information
Qing Ye committed Oct 7, 2021
1 parent e615f01 commit db2a4f4
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions feature_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/go-coldbrew/feature-flags/engines/unleash"
)

var client engines.FeatureFlag
var Client engines.FeatureFlag

const (
EngineUnleash = "unleash"
Expand All @@ -19,7 +19,7 @@ func Initialize(appName string, cfg config.Config) error {
var err error
switch cfg.FeatureFlagEngine {
case EngineUnleash:
client, err = unleash.Initialize(appName, cfg.UnleashConfig)
Client, err = unleash.Initialize(appName, cfg.UnleashConfig)
return err
default:
return fmt.Errorf("unsupported feature flag engine: %s", cfg.FeatureFlagEngine)
Expand All @@ -28,18 +28,18 @@ func Initialize(appName string, cfg config.Config) error {

// IsEnabled check if a feature flag is enabled, returns false if client is not initialized
func IsEnabled(name string, ctx engines.Context) bool {
if client == nil {
if Client == nil {
return false
}

return client.IsEnabled(name, ctx)
return Client.IsEnabled(name, ctx)
}

// GetVariant get variant for a feature flag, returns disabled variant if client is not initialised
func GetVariant(name string, ctx engines.Context) *engines.Variant {
if client == nil {
if Client == nil {
return engines.DisabledVariant
}

return client.GetVariant(name, ctx)
return Client.GetVariant(name, ctx)
}

0 comments on commit db2a4f4

Please sign in to comment.