trafficcontrol

package
v0.15.2 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2020 License: Apache-2.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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