circuitbreaker

package
v0.43.2 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package circuitbreaker provides a circuit breaker pattern implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action func() (interface{}, error)

Action function to execute in circuit breaker.

type CircuitBreaker

type CircuitBreaker struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

CircuitBreaker implementation.

func New

func New(name string, s Setting) (*CircuitBreaker, error)

New constructor.

func (*CircuitBreaker) Execute

func (cb *CircuitBreaker) Execute(act Action) (interface{}, error)

Execute the function enclosed.

type OpenError

type OpenError struct {
}

OpenError defines a open error.

func (OpenError) Error

func (oe OpenError) Error() string

type Setting

type Setting struct {
	// The threshold for the circuit to open.
	FailureThreshold uint
	// The timeout after which we set the state to half-open and allow a retry.
	RetryTimeout time.Duration
	// The threshold of the retry successes which returns the state to open.
	RetrySuccessThreshold uint
	// The threshold of how many retry executions are allowed when the status is half-open.
	MaxRetryExecutionThreshold uint
}

Setting definition.

Jump to

Keyboard shortcuts

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