iphash

package module
v0.0.0-...-0e4d407 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2019 License: MIT Imports: 6 Imported by: 1

README

ip-hash

ip-hash is balancing algorithm, based on round-robin.

Requrement

Go (>= 1.8)

Installation

go get github.com/hlts2/ip-hash

Example

ip, _ := iphash.New([]*url.URL{
    {Host: "192.168.33.10"},
    {Host: "192.168.33.11"},
    {Host: "192.168.33.12"},
 })

ip.Next(&url.URL{Host: "192.168.33.10"})  // {Host: "192.168.33.10"}
ip.Next(&url.URL{Host: "192.168.33.10"})  // {Host: "192.168.33.10"}
ip.Next(&url.URL{Host: "192.168.33.44"})  // {Host: "192.168.33.11"}
ip.Next(&url.URL{Host: "192.168.33.44"})  // {Host: "192.168.33.11"}

Author

hlts2

LICENSE

ip-hash 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 IPHash

type IPHash interface {
	Next(in *url.URL) *url.URL
}

IPHash is base ip-hash interface

func New

func New(urls []*url.URL) (IPHash, error)

New returns IPHash(*iphash) object

Jump to

Keyboard shortcuts

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