featuregate

package
v0.0.0-...-cb950d2 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Values for PreRelease.
	Alpha = prerelease("ALPHA")
	Beta  = prerelease("BETA")
	GA    = prerelease("")
)

Variables

View Source
var (
	ErrInited    = errors.New("feature gate is already inited")
	ErrNotInited = errors.New("feature gate is not inited")
)

Functions

func AddFeatureSpec

func AddFeatureSpec(key Feature, spec FeatureSpec) error

func Enabled

func Enabled(key Feature) bool

func Set

func Set(value string) error

func SetFeatureState

func SetFeatureState(key Feature, enable bool) error

func SetFromMap

func SetFromMap(m map[string]bool) error

func StartInit

func StartInit()

func Subscribe

func Subscribe(key Feature, timeout time.Duration) (bool, error)

func WaitInitFinsh

func WaitInitFinsh() error

Types

type BaseFeatureSpec

type BaseFeatureSpec struct {
	DefaultValue    bool
	IsLockedDefault bool
	PreReleaseValue prerelease
	// contains filtered or unexported fields
}

BaseFeatureSpec is a basic implementation of FeatureSpec. Usually, a feature spec just need an init func.

func (*BaseFeatureSpec) Default

func (spec *BaseFeatureSpec) Default() bool

func (*BaseFeatureSpec) InitFunc

func (spec *BaseFeatureSpec) InitFunc()

func (*BaseFeatureSpec) LockToDefault

func (spec *BaseFeatureSpec) LockToDefault() bool

func (*BaseFeatureSpec) PreRelease

func (spec *BaseFeatureSpec) PreRelease() prerelease

func (*BaseFeatureSpec) SetState

func (spec *BaseFeatureSpec) SetState(enable bool)

func (*BaseFeatureSpec) State

func (spec *BaseFeatureSpec) State() bool

type Feature

type Feature string
const (
	XdsMtlsEnable      Feature = "XdsMtlsEnable"
	PayLoadLimitEnable Feature = "PayLoadLimitEnable"
	MultiTenantMode    Feature = "MultiTenantMode"
)

type FeatureGate

type FeatureGate struct {
	// contains filtered or unexported fields
}

func NewFeatureGate

func NewFeatureGate() *FeatureGate

func (*FeatureGate) AddFeatureSpec

func (fg *FeatureGate) AddFeatureSpec(key Feature, spec FeatureSpec) error

AddFeatureSpec adds feature to the featureGate. features should be added by AddFeatureSpec

func (*FeatureGate) Enabled

func (fg *FeatureGate) Enabled(key Feature) bool

Enabled returns true if the key is enabled.

func (*FeatureGate) Set

func (fg *FeatureGate) Set(value string) error

Set parses and stores flag gates for known features from a string like feature1=true,feature2=false,...

func (*FeatureGate) SetFeatureState

func (fg *FeatureGate) SetFeatureState(key Feature, enable bool) error

SetFeatureState sets feature enablement state for the feature

func (*FeatureGate) SetFromMap

func (fg *FeatureGate) SetFromMap(m map[string]bool) error

SetFromMap stores flag gates for known features from a map[string]bool or returns an error

func (*FeatureGate) StartInit

func (fg *FeatureGate) StartInit()

StartInit triggers init functions of feature

func (*FeatureGate) Subscribe

func (fg *FeatureGate) Subscribe(key Feature, timeout time.Duration) (bool, error)

Subscribe waits the feature is ready, and returns the feature is enabled or not. The timeout is the max wait time duration for subscribe. If timeout is zero, means no timeout.

func (*FeatureGate) WaitInitFinsh

func (fg *FeatureGate) WaitInitFinsh() error

type FeatureSpec

type FeatureSpec interface {
	// Default is the default enablement state for the feature
	Default() bool
	// LockToDefault indicates that the feature is locked to its default and cannot be changed
	LockToDefault() bool
	// SetState sets the enablement state for the feature
	SetState(enable bool)
	// State indicates the feature enablement
	State() bool
	// InitFunc used to init process when StartInit is invoked
	InitFunc()
	// PreRelease indicates the maturity level of the feature
	PreRelease() prerelease
}

Jump to

Keyboard shortcuts

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