Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/hlts2/ip-hash

ip-hash balancing algorithm, based on round-robin.
https://github.com/hlts2/ip-hash

algorithm balancer balancing balancing-algorithm go golang golang-library goroutine-safe ip ip-hash library round-robin threadsafe

Last synced: about 1 month ago
JSON representation

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

Awesome Lists containing this project

README

        

# ip-hash
ip-hash is balancing algorithm, based on [round-robin](https://github.com/hlts2/round-robin).

## Requrement

Go (>= 1.8)

## Installation

```shell
go get github.com/hlts2/ip-hash
```

## Example
```go
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](https://github.com/hlts2)

## LICENSE
ip-hash released under MIT license, refer [LICENSE](https://github.com/hlts2/ip-hash/blob/master/LICENSE) file.