hystrix

package
v1.7.21 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultCheckHystrixInterval = 10     // unit is Second
	DefaultCheckAliveInterval   = 60     // unit is Second
	DefaultCleanHistoryInterval = 60 * 5 // unit is Second
	DefaultMaxFailedNumber      = 100
	DefaultReserveMinutes       = 30
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CheckFunc

type CheckFunc func() bool

type Counter

type Counter interface {
	Clear()
	Count() int64
	Dec(int64)
	Inc(int64)
}

Counter incremented and decremented base on int64 value.

func NewCounter

func NewCounter() Counter

NewCounter constructs a new StandardCounter.

type Hystrix

type Hystrix interface {
	// Do begin do check
	Do()
	// RegisterAliveCheck register check Alive func
	RegisterAliveCheck(CheckFunc)
	// RegisterHystrixCheck register check Hystrix func
	RegisterHystrixCheck(CheckFunc)
	// IsHystrix return is Hystrix status
	IsHystrix() bool
	// TriggerHystrix trigger Hystrix status
	TriggerHystrix()
	// TriggerAlive trigger Alive status
	TriggerAlive()
	// SetCheckInterval set interval for doCheckHystric and doCheckAlive, unit is Second
	SetCheckInterval(int, int)

	// GetCounter get lasted Counter with time key
	GetCounter() Counter

	// SetMaxFailed set max failed count for hystrix default counter
	SetMaxFailedNumber(int64)
}

func NewHystrix

func NewHystrix(checkAlive CheckFunc, checkHysrix CheckFunc) Hystrix

NewHystrix create new Hystrix, config with CheckAliveFunc and checkAliveInterval, unit is Minute

type StandHystrix

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

func (*StandHystrix) Do

func (h *StandHystrix) Do()

func (*StandHystrix) GetCounter

func (h *StandHystrix) GetCounter() Counter

GetCounter get lasted Counter with time key

func (*StandHystrix) IsHystrix

func (h *StandHystrix) IsHystrix() bool

func (*StandHystrix) RegisterAliveCheck

func (h *StandHystrix) RegisterAliveCheck(check CheckFunc)

func (*StandHystrix) RegisterHystrixCheck

func (h *StandHystrix) RegisterHystrixCheck(check CheckFunc)

func (*StandHystrix) SetCheckInterval

func (h *StandHystrix) SetCheckInterval(hystrixInterval, aliveInterval int)

func (*StandHystrix) SetMaxFailedNumber

func (h *StandHystrix) SetMaxFailedNumber(number int64)

SetMaxFailed set max failed count for hystrix default counter

func (*StandHystrix) TriggerAlive

func (h *StandHystrix) TriggerAlive()

func (*StandHystrix) TriggerHystrix

func (h *StandHystrix) TriggerHystrix()

type StandardCounter

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

StandardCounter is the standard implementation of a Counter

func (*StandardCounter) Clear

func (c *StandardCounter) Clear()

Clear sets the counter to zero.

func (*StandardCounter) Count

func (c *StandardCounter) Count() int64

Count returns the current count.

func (*StandardCounter) Dec

func (c *StandardCounter) Dec(i int64)

Dec decrements the counter by the given amount.

func (*StandardCounter) Inc

func (c *StandardCounter) Inc(i int64)

Inc increments the counter by the given amount.

Jump to

Keyboard shortcuts

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