Documentation ¶
Overview ¶
Package loadbalance provides the logic to load balance the incoming connections to the upstream servers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrHealthCheckFailedAfterRetry is returned when health check fails after retry limit ErrHealthCheckFailedAfterRetry = errors.New("health check failed after retry limit") // ErrDialerTimeoutExceeded is returned when dialer timeout is exceeded. ErrDialerTimeoutExceeded = errors.New("dialer timeout exceeded") // ErrDialerIsNil is returned when dialer is nil. ErrDialerIsNil = errors.New("dialer is nil") )
Functions ¶
func HealthCheck ¶
func HealthCheck( ctx context.Context, server UpstreamServerInterface, dialer NetDialerInterface, ) (bool, error)
HealthCheck performs a health check on an upstream server.
Types ¶
type NetDialerInterface ¶
type UpstreamServerInterface ¶
type UpstreamServerInterface interface { // GetAddress returns the address of the server. GetAddress() string // IsHealthy returns the health status of the server. IsHealthy() bool // SetHealthy sets the health status of the server. SetHealthy(healthy bool) // IncrementConnectionCount increments the number of connections to the server by 1. IncrementConnectionCount() // DecrementConnectionCount decrements the number of connections to the server by 1. DecrementConnectionCount() // GetConnectionCount returns the number of connections to the server. GetConnectionCount() int }
func GetNextUpstreamServer ¶
func GetNextUpstreamServer(upstreamServers []UpstreamServerInterface) (UpstreamServerInterface, error)
Click to show internal directories.
Click to hide internal directories.