circuitbreak

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultStatus    = "open"
	DefaultThreshold = 10
	DefaultMaxRetry  = 3
	DefaultInterval  = 30
)

Variables

View Source
var (
	CircuitCloseErr   = errors.New("circuit has been closed due to too many failed request")
	ExceedMaxRetryErr = errors.New("circuit is in halfopen status and the retry time has exceed threshold")
)
View Source
var (
	CacheCircuitIsOpenErr = errors.New("cache circuit is open now!")
)

Functions

func NewCacheCircuit

func NewCacheCircuit() *circuit.Circuit

Types

type CircuitClient

type CircuitClient struct {
	HttpClient http.Client
	UrlMap     map[string]*UrlItem
}

func NewCircuitClient

func NewCircuitClient() *CircuitClient

func NewCircuitClientWithInsecureSSL

func NewCircuitClientWithInsecureSSL() *CircuitClient

func (*CircuitClient) Do

func (cli *CircuitClient) Do(req *http.Request) (res *http.Response, err error)

type UrlItem

type UrlItem struct {
	Status       string
	FailNum      int
	Threshold    int
	RetryTime    int
	RetryChan    chan int
	MaxRetryTime int
	Interval     time.Duration
	L            *sync.Mutex
}

func NewUrlItem

func NewUrlItem() *UrlItem

func (*UrlItem) Add

func (i *UrlItem) Add()

func (*UrlItem) SetClose

func (i *UrlItem) SetClose()

func (*UrlItem) SetHalfOpen

func (i *UrlItem) SetHalfOpen()

func (*UrlItem) SetOpen

func (i *UrlItem) SetOpen()

func (*UrlItem) Sub

func (i *UrlItem) Sub()

Jump to

Keyboard shortcuts

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