roundrobin

package module
v0.0.0-...-2a846cd Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2023 License: MIT Imports: 3 Imported by: 14 modules, 13 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.

README

round-robin

round-robin is balancing algorithm written in golang

Installation

go get github.com/hlts2/round-robin

Example

rr, _ := roundrobin.New(
    &url.URL{Host: "192.168.33.10"},
    &url.URL{Host: "192.168.33.11"},
    &url.URL{Host: "192.168.33.12"},
    &url.URL{Host: "192.168.33.13"},
)

rr.Next() // {Host: "192.168.33.10"}
rr.Next() // {Host: "192.168.33.11"}
rr.Next() // {Host: "192.168.33.12"}
rr.Next() // {Host: "192.168.33.13"}
rr.Next() // {Host: "192.168.33.10"}
rr.Next() // {Host: "192.168.33.11"}

Author

hlts2

LICENSE

round-robin released under MIT license, refer LICENSE file.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrServersNotExists = errors.New("servers dose not exist")

ErrServersNotExists is the error that servers dose not exists

Functions

This section is empty.

Types

type RoundRobin

type RoundRobin interface {
	Next() *url.URL
}

RoundRobin is an interface for representing round-robin balancing.

func New

func New(urls ...*url.URL) (RoundRobin, error)

New returns RoundRobin implementation(*roundrobin).

Jump to

Keyboard shortcuts

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