cbreaker

package
v0.0.0-...-7b8bf0e Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2015 License: Apache-2.0 Imports: 8 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 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) NewHandler

func (c *Spec) NewHandler(next http.Handler) (http.Handler, error)

NewMiddleware vulcan library compatible middleware

func (*Spec) String

func (c *Spec) String() string

Jump to

Keyboard shortcuts

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