xt

package
v0.11.35 Latest Latest
Warning

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

Go to latest
Published: May 27, 2020 License: Apache-2.0 Imports: 7 Imported by: 6

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: requireMinCost + (math.MaxUint16 - 1),
	},
	Default: &precedence{
		name:    "default",
		minCost: defaultMinCost,
		maxCost: defaultMinCost + (math.MaxUint16 - 1),
	},
	Failed: &precedence{
		name:    "failed",
		minCost: failedMinCost,
		maxCost: failedMinCost + (math.MaxUint16 - 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
	GetTerminatorStats() Stats
}

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)
	GetCost(terminatorId string) uint32
	GetStats(terminatorId string) Stats
	GetPrecedence(terminatorId string) Precedence
	SetPrecedence(terminatorId string, precedence Precedence)
	SetPrecedenceCost(terminatorId string, weight uint16)
	UpdatePrecedenceCost(terminatorId string, updateF func(uint16) uint16)
	GetPrecedenceCost(terminatorId string) uint16
	TerminatorCreated(terminatorId string)
}

func GlobalCosts

func GlobalCosts() Costs

type DefaultEventVisitor

type DefaultEventVisitor struct{}

func (DefaultEventVisitor) VisitDialFailed

func (visitor DefaultEventVisitor) VisitDialFailed(TerminatorEvent)

func (DefaultEventVisitor) VisitDialSucceeded

func (visitor DefaultEventVisitor) VisitDialSucceeded(TerminatorEvent)

func (DefaultEventVisitor) VisitSessionEnded

func (visitor DefaultEventVisitor) VisitSessionEnded(TerminatorEvent)

type EventVisitor

type EventVisitor interface {
	VisitDialFailed(event TerminatorEvent)
	VisitDialSucceeded(event TerminatorEvent)
	VisitSessionEnded(event TerminatorEvent)
}

type Factory

type Factory interface {
	GetStrategyName() string
	NewStrategy() Strategy
}

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
	// contains filtered or unexported methods
}

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() map[uint32][]byte
	GetCreatedAt() time.Time
}

func TList

func TList(terminators ...Terminator) []Terminator

type TerminatorEvent

type TerminatorEvent interface {
	GetTerminator() Terminator
	Accept(visitor EventVisitor)
}

func NewDialFailedEvent

func NewDialFailedEvent(terminator Terminator) TerminatorEvent

func NewDialSucceeded

func NewDialSucceeded(terminator Terminator) TerminatorEvent

func NewSessionEnded

func NewSessionEnded(terminator Terminator) TerminatorEvent

Jump to

Keyboard shortcuts

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