ippool

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: May 7, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateIPRange

func CreateIPRange(iprange string) ([]netip.Addr, error)

create array of IP addresses from IP range for example "192.168.0-1.1-5" will converted to [192.168.0.1 192.168.0.2 192.168.0.3 192.168.0.4 192.168.0.5 192.168.1.1 192.168.1.2 192.168.1.3 192.168.1.4 192.168.1.5]

Types

type Auto added in v0.2.2

type Auto struct {
}

func (*Auto) FindServer added in v0.2.2

func (m *Auto) FindServer(sIP string, p []Server) (*Server, error)

func (*Auto) Rebalance added in v0.2.2

func (m *Auto) Rebalance(p []Server)

type BalancingMethod added in v0.2.2

type BalancingMethod interface {
	FindServer(ip string, p []Server) (*Server, error)
	Rebalance([]Server)
}

func NewBalancingMethod added in v0.2.2

func NewBalancingMethod(name string) (BalancingMethod, error)

type Filter

type Filter struct {
	// contains filtered or unexported fields
}

the struct that Contains array of filgerElements

func (*Filter) Add

func (f *Filter) Add(pool *Pool, srvpool *ServerPool)

i don't know that to say

func (*Filter) SetBalancingMethod added in v0.2.2

func (f *Filter) SetBalancingMethod(bm string) error

func (*Filter) SetLogFile added in v0.2.2

func (f *Filter) SetLogFile(logDir string) error

func (*Filter) WhatPool

func (f *Filter) WhatPool(ip string) (*ServerPool, error)

search what pool should handle request

type HashIP added in v0.2.2

type HashIP struct {
	// contains filtered or unexported fields
}

func (*HashIP) FindServer added in v0.2.2

func (m *HashIP) FindServer(sIP string, p []Server) (*Server, error)

func (*HashIP) Rebalance added in v0.2.2

func (m *HashIP) Rebalance(p []Server)

type LeastConnections added in v0.2.2

type LeastConnections struct {
}

func (*LeastConnections) FindServer added in v0.2.2

func (m *LeastConnections) FindServer(sIP string, p []Server) (*Server, error)

func (*LeastConnections) Rebalance added in v0.2.2

func (m *LeastConnections) Rebalance(p []Server)

type None added in v0.2.2

type None struct {
}

func (*None) FindServer added in v0.2.2

func (m *None) FindServer(sIP string, p []Server) (*Server, error)

func (*None) Rebalance added in v0.2.2

func (m *None) Rebalance(p []Server)

type Pool

type Pool struct {
	// contains filtered or unexported fields
}

the struct that keep clients addresses caontain IP addresses "192.168.0.1" and IP networks "192.168.0.0/24"

func NewPool

func NewPool(ip ...string) (*Pool, error)

create and return new Pool

func (*Pool) Add

func (p *Pool) Add(ip string) error

add IP or IP range or network to the pool

func (*Pool) AddArr

func (ar *Pool) AddArr(arr []string) error

add IP or IP range or network to the pool from range of strings

func (*Pool) Contains added in v0.2.2

func (p *Pool) Contains(searchIP string) (bool, error)

check the IP addresse in pool or not return true if pool contain IP or pool contain networm what contain ip

func (*Pool) Empty added in v0.2.2

func (p *Pool) Empty() bool

func (*Pool) String

func (ar *Pool) String() string

display all IP addresses and networks

type Random added in v0.2.2

type Random struct {
	// contains filtered or unexported fields
}

func (*Random) FindServer added in v0.2.2

func (m *Random) FindServer(sIP string, p []Server) (*Server, error)

func (*Random) Rebalance added in v0.2.2

func (m *Random) Rebalance(p []Server)

type RoundRobin added in v0.2.2

type RoundRobin struct {
	// contains filtered or unexported fields
}

func (*RoundRobin) FindServer added in v0.2.2

func (m *RoundRobin) FindServer(sIP string, p []Server) (*Server, error)

func (*RoundRobin) Rebalance added in v0.2.2

func (m *RoundRobin) Rebalance(p []Server)

type Server

type Server struct {
	Addr     netip.Addr
	Broken   bool
	Weight   int
	Priority float64

	MaxFails                 int
	AvgDataExchangeTime      int64
	AvgConnectTime           int64
	ConnectionsNumber        int
	CurrentConnectionsNumber int
	// contains filtered or unexported fields
}

func NewServer

func NewServer(addr netip.Addr, weight, maxFails, breakTime int) *Server

func (*Server) CheckLogFile added in v0.2.2

func (s *Server) CheckLogFile()

func (*Server) Connect

func (s *Server) Connect(proto, port string) (net.Conn, error)

func (*Server) Disconnect

func (s *Server) Disconnect(conn net.Conn) error

func (*Server) ExchangeData

func (s *Server) ExchangeData(client net.Conn, server net.Conn)

func (*Server) Fail

func (s *Server) Fail()

func (*Server) SetConfig

func (s *Server) SetConfig(weight, maxFails, breakTime string) error

func (*Server) SetLogFile added in v0.2.2

func (s *Server) SetLogFile(logDir string) error

type ServerPool

type ServerPool struct {
	Servers []Server
	Broken  []Server
	// contains filtered or unexported fields
}

the struct that keep servers addresses contain only IP addresses

func NewServerPool

func NewServerPool(m map[string]interface{}) (*ServerPool, error)

create and return new ServerPool

func (*ServerPool) Add

func (p *ServerPool) Add(addresses string, config map[string]interface{}) error

add IP address in servers pool

func (*ServerPool) AddFromMap

func (p *ServerPool) AddFromMap(m map[string]interface{}) error

add IP address in servers pool from array

func (*ServerPool) Contains

func (p *ServerPool) Contains(searchIP string) (bool, error)

check the server IP in pool or not return true if pool contain IP

func (*ServerPool) FindServer added in v0.2.2

func (s *ServerPool) FindServer(ip string) (*Server, error)

func (*ServerPool) Rebalance added in v0.2.2

func (s *ServerPool) Rebalance()

func (*ServerPool) SetBalancingMethod added in v0.2.2

func (s *ServerPool) SetBalancingMethod(name string) error

func (*ServerPool) SetConfig

func (p *ServerPool) SetConfig(weight, maxFails, breakTime string) error

func (*ServerPool) SetLogFile added in v0.2.2

func (s *ServerPool) SetLogFile(logDir string) error

func (*ServerPool) UpdateBroken added in v0.2.2

func (s *ServerPool) UpdateBroken()

Jump to

Keyboard shortcuts

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