Documentation ¶
Index ¶
- Variables
- type BalancerPrioritySet
- type Breaker
- type CallMeter
- func (meter *CallMeter) Calls() float64
- func (meter *CallMeter) CallsInLastPeriod(period time.Duration) float64
- func (meter *CallMeter) IsActive() bool
- func (meter *CallMeter) SetActive(active bool)
- func (meter *CallMeter) TimeSpent() float64
- func (meter *CallMeter) UpdateTimeSpent(duration time.Duration)
- type MeasuredStorage
- type Node
- type NodeBreaker
- type ResponseTimeBalancer
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoActiveNodes is issued if all nodes are inactive ErrNoActiveNodes = fmt.Errorf("Balancer has no nodes to call") )
Functions ¶
This section is empty.
Types ¶
type BalancerPrioritySet ¶
type BalancerPrioritySet struct {
// contains filtered or unexported fields
}
BalancerPrioritySet selects storage by priority and availability
func NewBalancerPrioritySet ¶
func NewBalancerPrioritySet(storagesConfig config.Storages, backends map[string]http.RoundTripper) *BalancerPrioritySet
NewBalancerPrioritySet configures prioritized balancers stack
func (*BalancerPrioritySet) GetMostAvailable ¶
func (bps *BalancerPrioritySet) GetMostAvailable(skipNodes ...Node) *MeasuredStorage
GetMostAvailable returns balancer member
type CallMeter ¶
type CallMeter struct {
// contains filtered or unexported fields
}
CallMeter implements Node interface
func NewCallMeter ¶
func (*CallMeter) CallsInLastPeriod ¶
CallsInLastPeriod returns number of calls in last duration
func (*CallMeter) UpdateTimeSpent ¶
UpdateTimeSpent aggregates data about call duration
type MeasuredStorage ¶
type MeasuredStorage struct { Node Breaker http.RoundTripper Name string }
MeasuredStorage coordinates metrics collection
func (*MeasuredStorage) IsActive ¶
func (ms *MeasuredStorage) IsActive() bool
IsActive checks Breaker status propagates it to Node compound
type Node ¶
type Node interface { Calls() float64 TimeSpent() float64 IsActive() bool SetActive(bool) UpdateTimeSpent(time.Duration) }
Node is interface of call node
type NodeBreaker ¶
type NodeBreaker struct {
// contains filtered or unexported fields
}
NodeBreaker is implementation of Breaker interface
func (*NodeBreaker) Record ¶
func (breaker *NodeBreaker) Record(duration time.Duration, success bool) bool
Record collects call data and returns bool if breaker should be opened
func (*NodeBreaker) ShouldOpen ¶
func (breaker *NodeBreaker) ShouldOpen() bool
ShouldOpen checks if breaker should be opened
type ResponseTimeBalancer ¶
type ResponseTimeBalancer struct {
Nodes []Node
}
ResponseTimeBalancer proxies calls to balancing nodes