trafficcontrol

package
v0.6.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Configuration

type Configuration struct {
	Type         Type           `yaml:"type"`
	DefaultValue *bool          `yaml:"defaultValue"`
	RuntimeKey   string         `yaml:"runtimeKey" validate:"nonzero"`
	InitTimeout  *time.Duration `yaml:"initTimeout"`
}

Configuration configures the traffic controller.

func (*Configuration) NewTrafficController

func (c *Configuration) NewTrafficController(
	store kv.Store,
	instrumentOpts instrument.Options,
) (Controller, error)

NewTrafficController creates a new traffic controller.

type Controller

type Controller interface {
	// Allow returns true if traffic is allowed.
	Allow() bool

	// Init initializes the traffic controller to watch the runtime updates.
	Init() error

	// Close closes the traffic controller.
	Close()
}

Controller controls traffic.

func NewTrafficDisabler

func NewTrafficDisabler(opts Options) Controller

NewTrafficDisabler creates a new traffic disabler.

func NewTrafficEnabler

func NewTrafficEnabler(opts Options) Controller

NewTrafficEnabler creates a new traffic enabler.

type Options

type Options interface {
	// SetStore sets the kv store.
	SetStore(store kv.Store) Options

	// Store returns the kv store.
	Store() kv.Store

	// SetDefaultValue sets the default value.
	SetDefaultValue(value bool) Options

	// DefaultValue returns the default value.
	DefaultValue() bool

	// SetRuntimeKey sets the runtime enable key,
	// which will override the default enabled value when present.
	SetRuntimeKey(value string) Options

	// RuntimeKey returns the runtime enable key,
	// which will override the default enabled value when present.
	RuntimeKey() string

	// SetInitTimeout sets the init timeout.
	SetInitTimeout(value time.Duration) Options

	// InitTimeout returns the init timeout.
	InitTimeout() time.Duration

	// SetInstrumentOptions sets the instrument options.
	SetInstrumentOptions(value instrument.Options) Options

	// InstrumentOptions returns the instrument options.
	InstrumentOptions() instrument.Options
}

Options configurates the traffic controller.

func NewOptions

func NewOptions() Options

NewOptions creates new Options.

type Type

type Type string

Type defines the type of the traffic controller.

var (
	// TrafficEnabler enables the traffic when the runtime value equals to true.
	TrafficEnabler Type = "trafficEnabler"
	// TrafficDisabler disables the traffic when the runtime value equals to true.
	TrafficDisabler Type = "trafficDisabler"
)

func (*Type) UnmarshalYAML

func (t *Type) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML unmarshals TrafficControllerType from yaml.

Jump to

Keyboard shortcuts

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