Documentation
¶
Overview ¶
Package optimizer provides a PT 2.0 Go API wrapper around the connections used
Index ¶
- type Client
- type FirstStrategy
- type RandomStrategy
- type RotateStrategy
- type Strategy
- func NewFirstStrategy(transports []TransportDialer) Strategy
- func NewMinimizeDialDuration(transport []TransportDialer) Strategy
- func NewRandomStrategy(transports []TransportDialer) Strategy
- func NewRotateStrategy(transports []TransportDialer) Strategy
- func NewTrackStrategy(transport []TransportDialer) Strategy
- type TrackStrategy
- type TransportDialer
- type TransportListener
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { Transports []TransportDialer Strategy Strategy }
Client contains the two parameters needed to use Optimizer.
func NewOptimizerClient ¶
func NewOptimizerClient(Transports []TransportDialer, Strategy Strategy) *Client
NewOptimizerClient is the initializer
type FirstStrategy ¶
type FirstStrategy struct {
// contains filtered or unexported fields
}
FirstStrategy returns the first strategy in the array
func (*FirstStrategy) Choose ¶
func (strategy *FirstStrategy) Choose() TransportDialer
Choose selects a transport in the array
func (*FirstStrategy) Report ¶
func (strategy *FirstStrategy) Report(TransportDialer, bool, float64)
Report returns if the transport was successful and how long the connection took
type RandomStrategy ¶
type RandomStrategy struct {
// contains filtered or unexported fields
}
RandomStrategy returns a transport at random
func (*RandomStrategy) Choose ¶
func (strategy *RandomStrategy) Choose() TransportDialer
Choose selects a transport in the array
func (*RandomStrategy) Report ¶
func (strategy *RandomStrategy) Report(TransportDialer, bool, float64)
Report returns if the transport was successful and how long the connection took
type RotateStrategy ¶
type RotateStrategy struct {
// contains filtered or unexported fields
}
RotateStrategy cycles through the list of transports, using a different one each time
func (*RotateStrategy) Choose ¶
func (strategy *RotateStrategy) Choose() TransportDialer
Choose selects a transport in the array
func (*RotateStrategy) Report ¶
func (strategy *RotateStrategy) Report(TransportDialer, bool, float64)
Report returns if the transport was successful and how long the connection took
type Strategy ¶
type Strategy interface { Choose() TransportDialer Report(transport TransportDialer, success bool, durationElapsed float64) }
Strategy is the method used to choose a transport
func NewFirstStrategy ¶
func NewFirstStrategy(transports []TransportDialer) Strategy
NewFirstStrategy initializes FirstStrategy
func NewMinimizeDialDuration ¶
func NewMinimizeDialDuration(transport []TransportDialer) Strategy
NewMinimizeDialDuration initializes minimizeDialDuration
func NewRandomStrategy ¶
func NewRandomStrategy(transports []TransportDialer) Strategy
NewRandomStrategy initializes RandomStrategy
func NewRotateStrategy ¶
func NewRotateStrategy(transports []TransportDialer) Strategy
NewRotateStrategy initializes RotateStrategy
func NewTrackStrategy ¶
func NewTrackStrategy(transport []TransportDialer) Strategy
NewTrackStrategy initializes TrackStrategy
type TrackStrategy ¶
type TrackStrategy struct {
// contains filtered or unexported fields
}
TrackStrategy assigns a score to each transport and server that is remembered and used to choose the best option
func (*TrackStrategy) Choose ¶
func (strategy *TrackStrategy) Choose() TransportDialer
Choose selects a transport in the array
func (*TrackStrategy) Report ¶
func (strategy *TrackStrategy) Report(transport TransportDialer, success bool, _ float64)
Report returns if the transport was successful and how long the connection took
type TransportDialer ¶ added in v3.0.2
TransportDialer is a program that transforms network traffic