featureflag

package
v2.35.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 8, 2022 License: MIT Imports: 2 Imported by: 0

README

Feature Flag

This helper will allow you to use Flagr as Feature Flag service. Read more about Feature Flag in here and Flagr in here.

Usage

Create FeatureFlagConfig first then call NewFeatureFlag by injecting config and context into it. Note : Make sure you append /api/v1 in the BaseURL.

    config := &FeatureFlagConfig{
		BaseURL:  "http://some-url/api/v1",
		Username: "someuser",
		Password: "somepassword",
	}
	ctx := context.Background()
	featureFlag := NewFeatureFlag(config, ctx)
Evaluate

Evaluate by variant and get the distribution result.

    ok, err := featureFlag.Eval('some-flag', 'some-variant')
Evaluate then execute function

Evaluate by variant and execute function if true.

    ok, err := featureFlag.EvalThenExecute('some-flag', 'some-variant', func() error {
        //Do something
        return err
    })

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFlagrClient

func NewFlagrClient(baseURL, username, password string, ctx context.Context) (*goflagr.APIClient, context.Context)

Types

type FeatureFlag

type FeatureFlag interface {
	EvalThenExecute(flag, variant string, featureFunc FeatureFunc) (ok bool, err error)
	Eval(flag, variant string) (ok bool, err error)
	EvalAttachment(flag string) (evalResult interface{}, err error)
}

func NewFeatureFlag

func NewFeatureFlag(conf *FeatureFlagConfig, ctx context.Context) FeatureFlag

type FeatureFlagConfig

type FeatureFlagConfig struct {
	Username string
	Password string
	BaseURL  string
	Debug    bool
}

type FeatureFunc

type FeatureFunc func() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL