lb

package
v0.0.0-...-ae88a46 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package lb

@author: xwc1125

Package lb

@author: xwc1125

Index

Constants

View Source
const (
	RoundRobin = "roundrobin"
	IPHash     = "iphash"
	CHash      = "chash"
	Rand       = "Rand"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type HashCBalance

type HashCBalance struct {
	// contains filtered or unexported fields
}

func (HashCBalance) Distribute

func (lb HashCBalance) Distribute(req *fasthttp.Request) int64

type HashIPBalance

type HashIPBalance struct {
	// contains filtered or unexported fields
}

HashIPBalance is hash IP loadBalance impl

func (HashIPBalance) Distribute

func (lb HashIPBalance) Distribute(ctx *fasthttp.Request) int64

Distribute select a server from servers using HashIPBalance

type LoadBalance

type LoadBalance interface {
	Distribute(ctx *fasthttp.Request) int64
}

LoadBalance .

func NewBalancer

func NewBalancer(upstreamDef *entity.UpstreamDef, ws []W) LoadBalance

NewBalancer ...

type RandBalance

type RandBalance struct {
	// contains filtered or unexported fields
}

RandBalance is rand loadBalance impl

func (RandBalance) Distribute

func (rb RandBalance) Distribute(req *fasthttp.Request) int64

type W

type W interface {
	Weight() int
}

W ...

type Weight

type Weight uint

Weight .

func (Weight) Weight

func (w Weight) Weight() int

Jump to

Keyboard shortcuts

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