featureflag

package
v0.0.0-...-8ff1004 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2019 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrRefresh = errors.New("feature flag changed, restart worker")

ErrRefresh indicates that the flag's Check result is no longer valid, and a new featureflag.Worker must be started to get a valid result.

Functions

func Manifold

func Manifold(config ManifoldConfig) dependency.Manifold

Manifold returns a dependency.Manifold that will run a FlagWorker and expose it to clients as a engine.Flag resource.

func NewWorker

func NewWorker(config Config) (worker.Worker, error)

NewWorker creates a feature flag worker with the specified config.

Types

type Config

type Config struct {
	Source   ConfigSource
	Logger   loggo.Logger
	FlagName string
	Invert   bool
}

Config holds the information needed by the featureflag worker.

func (Config) Value

func (config Config) Value() (bool, error)

Value returns whether the feature flag is set (inverted if necessary).

type ConfigSource

type ConfigSource interface {
	WatchControllerConfig() state.NotifyWatcher
	ControllerConfig() (controller.Config, error)
}

ConfigSource lets us get notifications of changes to controller configuration, and then get the changed config. (Primary implementation is State.)

type ManifoldConfig

type ManifoldConfig struct {
	StateName string

	FlagName  string
	Invert    bool
	Logger    loggo.Logger
	NewWorker func(Config) (worker.Worker, error)
}

ManifoldConfig holds the information necessary to run a featureflag.Worker in a dependency.Engine.

func (ManifoldConfig) Validate

func (config ManifoldConfig) Validate() error

Validate validates the manifold configuration.

type Worker

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

Worker implements worker.Worker and util.Flag, representing controller ownership of a model, such that the Flag's validity is tied to the Worker's lifetime.

func (*Worker) Check

func (flag *Worker) Check() bool

Check is part of the util.Flag interface.

Check returns whether the feature flag is set (or the not set, if Invert was set).

The validity of this result is tied to the lifetime of the Worker; once the worker has stopped, no inferences may be drawn from any Check result.

func (*Worker) Kill

func (flag *Worker) Kill()

Kill is part of the worker.Worker interface.

func (*Worker) Wait

func (flag *Worker) Wait() error

Wait is part of the worker.Worker interface.

Jump to

Keyboard shortcuts

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