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: 11

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