Documentation
¶
Index ¶
- type LeastConnected
- type LeastTraffic
- type Preference
- type ResponseTime
- type RoundRobin
- type Statistics
- func FirstAvailable(s []Statistics) []Statistics
- func MultiSort(s []Statistics, ip string, sticky string, mode string) ([]Statistics, error)
- func NewStatistics(UUID string, counterSize int) *Statistics
- func Random(s []Statistics) []Statistics
- func Sort(s []Statistics, ip string, sticky string, mode string) ([]Statistics, error)
- func Sticky(s []Statistics, id string) []Statistics
- func Topology(s []Statistics, ip string) []Statistics
- func WeighCalculation(s []Statistics) []Statistics
- func (s *Statistics) ClientsConnectedAdd(i int64)
- func (s *Statistics) ClientsConnectedGet() int64
- func (s *Statistics) ClientsConnectedSet(count int64)
- func (s *Statistics) ClientsConnectedSub(i int64)
- func (s *Statistics) ClientsConnectsAdd(i int64)
- func (s *Statistics) ClientsConnectsGet() int64
- func (s *Statistics) ClientsConnectsSet(count int64)
- func (s *Statistics) ClientsConnectsSub(i int64)
- func (s *Statistics) RXAdd(rx int64)
- func (s *Statistics) RXGet() int64
- func (s *Statistics) Reset()
- func (s *Statistics) ResponseTimeAdd(f float64)
- func (s *Statistics) ResponseTimeGet() float64
- func (s *Statistics) ResponseTimeValueGet() []float64
- func (s *Statistics) ResponseTimeValueMerge(f []float64)
- func (s *Statistics) SetWeighted(w int)
- func (s *Statistics) TXAdd(tx int64)
- func (s *Statistics) TXGet() int64
- func (s *Statistics) TimeCounterAdd()
- func (s *Statistics) TimeCounterGet() int
- func (s *Statistics) UUIDGet() string
- type Weighted
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LeastConnected ¶
type LeastConnected struct {
// contains filtered or unexported fields
}
LeastConnected based loadbalancing interface for statistics
func (LeastConnected) Less ¶
func (s LeastConnected) Less(i, j int) bool
Less implements LeastConnected based loadbalancing by sorting based on leastconnected counter
type LeastTraffic ¶
type LeastTraffic struct {
// contains filtered or unexported fields
}
LeastTraffic based loadbalancing
func (LeastTraffic) Less ¶
func (s LeastTraffic) Less(i, j int) bool
Less implements LeastTraffic based loadbalancing by sorting based on leasttraffic counter
type Preference ¶
type Preference struct {
// contains filtered or unexported fields
}
Preference based loadbalancing interface for statistic
func (Preference) Less ¶
func (s Preference) Less(i, j int) bool
Less implements preference based loadbalancing by sorting based on Preference counter
type ResponseTime ¶
type ResponseTime struct {
// contains filtered or unexported fields
}
ResponseTime based loadbalancing interface for statistics
func (ResponseTime) Less ¶
func (s ResponseTime) Less(i, j int) bool
Less implements ResponseTime based loadbalancing by sorting based on ResponseTime counter
type RoundRobin ¶
type RoundRobin struct {
// contains filtered or unexported fields
}
RoundRobin sorts records by Round robin
func (RoundRobin) Less ¶
func (s RoundRobin) Less(i, j int) bool
Less implements RoundRobin based loadbalancing by sorting based on selected counter
type Statistics ¶
type Statistics struct { *sync.RWMutex UUID string `json:"uuid"` ClientsConnected int64 `json:"clientsconnected"` ClientsConnects int64 `json:"clientsconnects"` RX int64 `json:"rx"` TX int64 `json:"tx"` Preference int `json:"preference"` Topology []string `json:"topology"` TimeCounter chan bool `json:"-"` // counts the elements TimeTimer int `json:"timetimer"` // time to keep elements ResponseTimeValue []float64 `json:"responsetimevalue"` Weighted int `json:"weighted"` // weighted value }
Statistics used to determain balancing
func FirstAvailable ¶
func FirstAvailable(s []Statistics) []Statistics
FirstAvailable Balance based on nothing, returns the first host entry this is used to limit the output to 1 host
func MultiSort ¶
func MultiSort(s []Statistics, ip string, sticky string, mode string) ([]Statistics, error)
MultiSort sorts statistics based on multiple modes
func NewStatistics ¶
func NewStatistics(UUID string, counterSize int) *Statistics
NewStatistics returns new statistics
func Random ¶
func Random(s []Statistics) []Statistics
Random implements the Random balance type, by randomizing the array provided
func Sort ¶
func Sort(s []Statistics, ip string, sticky string, mode string) ([]Statistics, error)
Sort sorts statistics based on value. ID can be a IP for ip based loadbalancing. ID van be sessionID for stickyness based loadbalancing.
func Sticky ¶
func Sticky(s []Statistics, id string) []Statistics
Sticky Balance based on Stickiness, the provided ID should always match the same node
func Topology ¶
func Topology(s []Statistics, ip string) []Statistics
Topology Balance based on Topology, this only returns stats where the ip matches the topolology
func WeighCalculation ¶
func WeighCalculation(s []Statistics) []Statistics
WeighCalculation implements a weighted form of loadbalancing
func (*Statistics) ClientsConnectedAdd ¶
func (s *Statistics) ClientsConnectedAdd(i int64)
ClientsConnectedAdd adds a client to the counter
func (*Statistics) ClientsConnectedGet ¶
func (s *Statistics) ClientsConnectedGet() int64
ClientsConnectedGet returns the clients connected
func (*Statistics) ClientsConnectedSet ¶
func (s *Statistics) ClientsConnectedSet(count int64)
ClientsConnectedSet adds a client to the counter
func (*Statistics) ClientsConnectedSub ¶
func (s *Statistics) ClientsConnectedSub(i int64)
ClientsConnectedSub adds a client to the counter
func (*Statistics) ClientsConnectsAdd ¶
func (s *Statistics) ClientsConnectsAdd(i int64)
ClientsConnectsAdd adds a client to the counter
func (*Statistics) ClientsConnectsGet ¶
func (s *Statistics) ClientsConnectsGet() int64
ClientsConnectsGet returns the clients requests
func (*Statistics) ClientsConnectsSet ¶
func (s *Statistics) ClientsConnectsSet(count int64)
ClientsConnectsSet adds a client to the counter
func (*Statistics) ClientsConnectsSub ¶
func (s *Statistics) ClientsConnectsSub(i int64)
ClientsConnectsSub adds a client to the counter
func (*Statistics) ResponseTimeAdd ¶
func (s *Statistics) ResponseTimeAdd(f float64)
ResponseTimeAdd adds a response time to the array, and cycles through them if full
func (*Statistics) ResponseTimeGet ¶
func (s *Statistics) ResponseTimeGet() float64
ResponseTimeGet gets current averate response time
func (*Statistics) ResponseTimeValueGet ¶
func (s *Statistics) ResponseTimeValueGet() []float64
ResponseTimeValueGet returns the responsetime values
func (*Statistics) ResponseTimeValueMerge ¶
func (s *Statistics) ResponseTimeValueMerge(f []float64)
ResponseTimeValueMerge merges 2 response time arrays
func (*Statistics) SetWeighted ¶
func (s *Statistics) SetWeighted(w int)
SetWeighted adds a weight to the counter
func (*Statistics) TimeCounterAdd ¶
func (s *Statistics) TimeCounterAdd()
TimeCounterAdd counter for entriest per X seconds
func (*Statistics) TimeCounterGet ¶
func (s *Statistics) TimeCounterGet() int
TimeCounterGet gets current count of the timer