circuitbreaker

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

README

Documentation

Overview

Package circuitbreaker

Index

Constants

This section is empty.

Variables

View Source
var ErrNotAllowed = errors.New("circuit breaker: not allowed for circuit open")

ErrNotAllowed error not allowed.

Functions

This section is empty.

Types

type Acceptable

type Acceptable func(err error) bool

Acceptable 自定义判定执行结果

type Breaker

type Breaker interface {
	// Name 熔断器名称
	Name() string

	// Allow 熔断方法,执行请求时必须手动上报执行结果
	Allow() error

	// Do 熔断方法,
	// req - 执行的函数
	// fallback - 支持自定义快速失败
	// acceptable - 支持自定义判定执行结果
	// 如果fallback和acceptable都为nil,自动上报执行结果
	Do(req func() error, fallback func(err error) error, acceptable Acceptable) error
}

type Breakers

type Breakers struct {
	// contains filtered or unexported fields
}

func NewBreakers

func NewBreakers() *Breakers

func (*Breakers) Add

func (b *Breakers) Add(breaker Breaker)

func (*Breakers) Allow

func (b *Breakers) Allow(breakerName string) error

func (*Breakers) Do

func (b *Breakers) Do(breakerName string, req func() error, fallback func(err error) error, acceptable Acceptable) error

func (*Breakers) Get

func (b *Breakers) Get(breakerName string) (Breaker, error)

Directories

Path Synopsis
Package hystrix
Package hystrix
sre
Package zerobreaker
Package zerobreaker
util
Package util
Package util

Jump to

Keyboard shortcuts

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