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 determines // 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 Cost ¶ added in v1.1.12
type Cost interface { Get() uint16 Inspect(terminatorId string) *inspect.TerminatorCostDetail }
type CostedTerminator ¶
type CostedTerminator interface { Terminator GetRouteCost() uint32 }
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 { ClearCost(terminatorId string) SetDynamicCost(terminatorId string, c Cost) GetDynamicCost(terminatorId string) uint16 GetCost(terminatorId string) Cost IterCosts(func(terminatorId string, cost Cost)) }
func GlobalCosts ¶
func GlobalCosts() Costs
type CreateCircuitParams ¶ added in v1.1.3
type CreateCircuitParams interface { GetServiceId() string GetClientId() *identity.TokenId GetLogContext() logcontext.Context }
type DefaultEventVisitor ¶
type DefaultEventVisitor struct{}
func (DefaultEventVisitor) VisitCircuitRemoved ¶
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 Precedence ¶
type Precedence interface { fmt.Stringer GetBaseCost() uint32 IsFailed() bool IsDefault() bool IsRequired() bool Unbias(cost uint32) uint32 GetBiasedCost(cost uint32) uint32 }
func GetPrecedenceForName ¶
func GetPrecedenceForName(name string) Precedence
type Registry ¶
type Registry interface { RegisterFactory(factory Factory) GetStrategy(name string) (Strategy, error) }
func GlobalRegistry ¶
func GlobalRegistry() Registry
type Strategy ¶
type Strategy interface { Select(param CreateCircuitParams, terminators []CostedTerminator) (CostedTerminator, PeerData, 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 GetPrecedence() Precedence GetCost() uint16 GetServiceId() string GetInstanceId() string GetRouterId() string GetBinding() string GetAddress() string GetPeerData() PeerData GetCreatedAt() time.Time GetHostId() string }
func TList ¶
func TList(terminators ...Terminator) []Terminator
type TerminatorEvent ¶
type TerminatorEvent interface { GetTerminator() Terminator Accept(visitor EventVisitor) }
func NewCircuitRemoved ¶
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.