cbreaker

package
Version: v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2014 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const Type = "cbreaker"

Variables

This section is empty.

Functions

func CliFlags

func CliFlags() []cli.Flag

func FromCli

func FromCli(c *cli.Context) (plugin.Middleware, error)

FromCli constructs the middleware from the command line arguments

func FromOther

func FromOther(c Spec) (plugin.Middleware, error)

FromOther is used to read spec from the serialized format

func GetSpec

func GetSpec() *plugin.MiddlewareSpec

Types

type Params

type Params struct {
	Condition threshold.Predicate
	Fallback  middleware.Middleware
	Options   circuitbreaker.Options
}

Params to instantiate circuit breaker middleware instance

type Spec

type Spec struct {
	// Condition is a JSON dictionary formula to set circuit breaker in "Tripped" state
	Condition string
	// Fallback is a JSON dictionary with fallback action, such as response or redirect
	Fallback interface{}

	// OnTripped defines JSON dict with action executed after (Standby -> Tripped) transition takes place
	OnTripped interface{}
	// OnStandby defines JSON dict with action executed after (Recovering -> Standby) transition takes place)
	OnStandby interface{}

	// FallbackDuration defines time period for circuit breaker to activate fallback scenario for all requests
	FallbackDuration time.Duration

	// Recovery duration defines time period for circuit breaker to increase traffic to the original upstream.
	RecoveryDuration time.Duration

	// CheckPeriod defines the period between circuit breaker checks
	CheckPeriod time.Duration
}

Spec defines circuit breaker middleware parameters

func NewSpec

func NewSpec(condition string, fallback, onTripped, onStandby interface{}, fallbackDuration, recoveryDuration, checkPeriod time.Duration) (*Spec, error)

NewSpec check parameters and returns new specification for the middleware

func (*Spec) NewMiddleware

func (c *Spec) NewMiddleware() (middleware.Middleware, error)

NewMiddleware vulcan library compatible middleware

func (*Spec) String

func (c *Spec) String() string

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL