hlts2 / ip-hash

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

About

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

License:MIT License


Languages

Language:Go 100.0%