Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Precedences = struct { // Required terminators should always be used in preference to non-required terminators // Example: The current active node in an active/passive setup. If the strategy determintes // that the current active has failed, it will drop the precedence and mark some other // terminator as Required Required Precedence // Default precedence is where terminators start Default Precedence // Failed means this terminator should only be used if all other terminators are also in a failed state // Example: A strategy might move a terminator to Failed if three dials in a row fail Failed Precedence // Unknown means this terminator was likely recently removed and should not be used unknown Precedence }{ Required: &precedence{ name: "required", minCost: requireMinCost, maxCost: defaultMinCost - 1, }, Default: &precedence{ name: "default", minCost: defaultMinCost, maxCost: failedMinCost - 1, }, Failed: &precedence{ name: "failed", minCost: failedMinCost, maxCost: unknownMinCost - 1, }, // contains filtered or unexported fields }
Precedences define the precedence levels
Functions ¶
This section is empty.
Types ¶
type CostedTerminator ¶
type CostedTerminator interface { Terminator GetRouteCost() uint32 GetPrecedence() Precedence }
func GetRelatedTerminators ¶
func GetRelatedTerminators(list []CostedTerminator) []CostedTerminator
In a list which is sorted by precedence, returns the terminators which have the same precedence as that of the first entry in the list
type Costs ¶
type Costs interface { SetPrecedenceChangeHandler(f func(terminatorId string, precedence Precedence)) ClearCost(terminatorId string) SetPrecedence(terminatorId string, precedence Precedence) SetDynamicCost(terminatorId string, weight uint16) UpdateDynamicCost(terminatorId string, updateF func(uint16) uint16) GetDynamicCost(terminatorId string) uint16 }
func GlobalCosts ¶
func GlobalCosts() Costs
type DefaultEventVisitor ¶
type DefaultEventVisitor struct{}
func (DefaultEventVisitor) VisitCircuitRemoved ¶ added in v0.16.92
func (visitor DefaultEventVisitor) VisitCircuitRemoved(TerminatorEvent)
func (DefaultEventVisitor) VisitDialFailed ¶
func (visitor DefaultEventVisitor) VisitDialFailed(TerminatorEvent)
func (DefaultEventVisitor) VisitDialSucceeded ¶
func (visitor DefaultEventVisitor) VisitDialSucceeded(TerminatorEvent)
type EventVisitor ¶
type EventVisitor interface { VisitDialFailed(event TerminatorEvent) VisitDialSucceeded(event TerminatorEvent) VisitCircuitRemoved(event TerminatorEvent) }
type FailureCosts ¶
type FailureCosts interface { Failure(terminatorId string) uint16 Success(terminatorId string) uint16 Clear(terminatorId string) CreditOverTime(credit uint8, period time.Duration) *time.Ticker }
func NewFailureCosts ¶
func NewFailureCosts(maxFailureCost uint16, failureCost uint8, successCredit uint8) FailureCosts
type Precedence ¶
type Precedence interface { fmt.Stringer IsFailed() bool IsDefault() bool IsRequired() bool Unbias(cost uint32) uint32 GetBiasedCost(cost uint32) uint32 // contains filtered or unexported methods }
func GetPrecedenceForName ¶ added in v0.13.0
func GetPrecedenceForName(name string) Precedence
type Registry ¶
type Registry interface { RegisterFactory(factory Factory) GetStrategy(name string) (Strategy, error) }
func GlobalRegistry ¶
func GlobalRegistry() Registry
type Stats ¶
type Stats interface { GetCost() uint32 GetPrecedence() Precedence }
type Strategy ¶
type Strategy interface { Select(terminators []CostedTerminator) (Terminator, error) HandleTerminatorChange(event StrategyChangeEvent) error NotifyEvent(event TerminatorEvent) }
type StrategyChangeEvent ¶
type StrategyChangeEvent interface { GetServiceId() string GetCurrent() []Terminator GetAdded() []Terminator GetChanged() []Terminator GetRemoved() []Terminator }
func NewStrategyChangeEvent ¶
func NewStrategyChangeEvent(serviceId string, current, added, changed, removed []Terminator) StrategyChangeEvent
type Terminator ¶
type Terminator interface { GetId() string GetCost() uint16 GetServiceId() string GetRouterId() string GetBinding() string GetAddress() string GetPeerData() PeerData GetCreatedAt() time.Time }
func TList ¶
func TList(terminators ...Terminator) []Terminator
type TerminatorEvent ¶
type TerminatorEvent interface { GetTerminator() Terminator Accept(visitor EventVisitor) }
func NewCircuitRemoved ¶ added in v0.16.92
func NewCircuitRemoved(terminator Terminator) TerminatorEvent
func NewDialFailedEvent ¶
func NewDialFailedEvent(terminator Terminator) TerminatorEvent
func NewDialSucceeded ¶
func NewDialSucceeded(terminator Terminator) TerminatorEvent
Click to show internal directories.
Click to hide internal directories.