Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/hlts2/least-connections

lock-free least-connections balancing algorithm written in golang
https://github.com/hlts2/least-connections

algorithm balancer balancing go golang goroutine-safe least-connected lock-free

Last synced: 4 days ago
JSON representation

lock-free least-connections balancing algorithm written in golang

Awesome Lists containing this project

README

        

# least-connections
least-connections is least-connections balancing algorithm written in golang

## Requrement

Go (>= 1.8)

## Installation

```shell
go get github.com/hlts2/least-connections
```

## Example

### Basic Example
```go
lc, err := New([]*url.URL{
{Host: "192.168.33.10"},
{Host: "192.168.33.11"},
{Host: "192.168.33.12"},
})

src1, done1 := lc.Next() // {Host: "192.168.33.10"}

src2, done2 := lc.Next() // {Host: "192.168.33.11"}

done1() // Reduce connection of src1

src3, done3 := lc.Next() // {Host: "192.168.33.10"}

```

## Author
[hlts2](https://github.com/hlts2)

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