lb

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2020 License: MIT Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotHandler = fmt.Errorf("error not handler")
)

Functions

func NewLBWithConfig

func NewLBWithConfig(conf *Config) (http.Handler, error)

Types

type Config

type Config struct {
	Policy   LoadBalancePolicyEnum `json:",omitempty"`
	Handlers []*Weight
}

type LoadBalancePolicyEnum

type LoadBalancePolicyEnum string
const (
	EnumRoundRobin LoadBalancePolicyEnum = "round_robin"
	EnumRandom     LoadBalancePolicyEnum = "random"
)

type Random

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

func NewRandom

func NewRandom(handlers []http.Handler) *Random

func (*Random) ServeHTTP

func (r *Random) ServeHTTP(rw http.ResponseWriter, req *http.Request)

type RoundRobin

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

func NewRoundRobin

func NewRoundRobin(handlers []http.Handler) *RoundRobin

func (*RoundRobin) ServeHTTP

func (r *RoundRobin) ServeHTTP(rw http.ResponseWriter, req *http.Request)

type Weight

type Weight struct {
	Weight  uint `json:",omitempty"`
	Handler http.Handler
}

Jump to

Keyboard shortcuts

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