iphash

package module
v0.0.0-...-478fc7e Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2025 License: MIT Imports: 6 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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
⌂ 换网址