Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
ErrNoAliveServers = errors.New("no alive replicas")
)
Functions ¶
This section is empty.
Types ¶
type Balancer ¶
type Balancer interface { // Next returns the next server to be used Next() (*common.Server, error) // Add adds a new server to the balancer Add(*common.Server) HealthChecker() *health.HealthChecker SetHealthChecker(*health.HealthChecker) }
Balancer is an interface that defines the behavior of a load balancer
type RR ¶
type RR struct { Hc *health.HealthChecker // contains filtered or unexported fields }
Round Robin Balancer will select the next server in the list of servers in a round robin fashion. This is the default balancer used by Mizan. Equivalent to Weighted Round Robin with all weights set to 1.
func (*RR) HealthChecker ¶
func (rr *RR) HealthChecker() *health.HealthChecker
func (*RR) SetHealthChecker ¶
func (rr *RR) SetHealthChecker(hc *health.HealthChecker)
type WRR ¶
type WRR struct { Hc *health.HealthChecker // contains filtered or unexported fields }
Weighted Round Robin Balancer This is a weighted version of the Round Robin Balancer Each server has a weight associated with it, and the load balancer will select the next server based on the weight of each server If the weight of server is not specified, it will be set to 1 TODO (Mo-Fatah): Add support for calculating live connecitons to each server and use that as a weight
func (*WRR) HealthChecker ¶
func (rr *WRR) HealthChecker() *health.HealthChecker
func (*WRR) SetHealthChecker ¶
func (rr *WRR) SetHealthChecker(hc *health.HealthChecker)