fflag

package
v0.0.0-...-e1e9d1d Latest Latest
Warning

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

Go to latest
Published: May 20, 2021 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package fflag defines the standard interface for feature flags.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockProvider

type MockProvider struct {
	BoolFunc    func(context.Context, string, bool, interface{}) (bool, error)
	StringFunc  func(context.Context, string, string, interface{}) (string, error)
	IntFunc     func(context.Context, string, int, interface{}) (int, error)
	Float64Func func(context.Context, string, float64, interface{}) (float64, error)
}

MockProvider is a test mock for the Provider interface.

func (*MockProvider) Bool

func (m *MockProvider) Bool(ctx context.Context, flag string, def bool, data interface{}) (bool, error)

func (*MockProvider) Float64

func (m *MockProvider) Float64(ctx context.Context, flag string, def float64, data interface{}) (float64, error)

func (*MockProvider) Int

func (m *MockProvider) Int(ctx context.Context, flag string, def int, data interface{}) (int, error)

func (*MockProvider) String

func (m *MockProvider) String(ctx context.Context, flag string, def string, data interface{}) (string, error)

type Provider

type Provider interface {
	// Bool returns a boolean for the specified flag, using data to evaluate the
	// variation to use. This data value is implementation-specific.  If the
	// context is cancelled, the operation stops and returns an error along with
	// the default value.
	Bool(ctx context.Context, flag string, defaultVal bool, data interface{}) (bool, error)

	// String returns a string for the specified flag, using data to evaluate the
	// variation to use. This data value is implementation-specific.  If the
	// context is cancelled, the operation stops and returns an error along with
	// the default value.
	String(ctx context.Context, flag string, defaultVal string, data interface{}) (string, error)

	// Int returns an integer for the specified flag, using data to evaluate the
	// variation to use. This data value is implementation-specific.  If the
	// context is cancelled, the operation stops and returns an error along with
	// the default value.
	Int(ctx context.Context, flag string, defaultVal int, data interface{}) (int, error)

	// Float64 returns a float for the specified flag, using data to evaluate the
	// variation to use. This data value is implementation-specific.  If the
	// context is cancelled, the operation stops and returns an error along with
	// the default value.
	Float64(ctx context.Context, flag string, defaultVal float64, data interface{}) (float64, error)
}

Provider defines the methods that provide feature flag variations.

Jump to

Keyboard shortcuts

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