Documentation ¶
Index ¶
- func CreateIPRange(iprange string) ([]netip.Addr, error)
- func CreateRange(rng string) ([]string, error)
- type Auto
- type BalancingMethod
- type Filter
- type HashIP
- type LeastConnections
- type None
- type Pool
- type Random
- type RoundRobin
- type Server
- func (s *Server) Connect(proto, port string) (net.Conn, error)
- func (s *Server) Disconnect(conn net.Conn) error
- func (s *Server) ExchangeData(client net.Conn, server net.Conn)
- func (s *Server) Fail()
- func (s *Server) SetConfig(weight, maxFails, breakTime string) error
- func (s *Server) SetLogFile(logDir string) error
- type ServerPool
- func (p *ServerPool) Add(serverNames string, config map[string]interface{}) error
- func (p *ServerPool) AddFromMap(m map[string]interface{}) error
- func (s *ServerPool) FindServer(ip string) (*Server, error)
- func (s *ServerPool) Rebalance()
- func (s *ServerPool) SetBalancingMethod(name string) error
- func (p *ServerPool) SetConfig(weight, maxFails, breakTime string) error
- func (s *ServerPool) SetLogFile(logDir string) error
- func (s *ServerPool) UpdateBroken()
- type ServerStats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateIPRange ¶
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]
func CreateRange ¶ added in v0.2.5
create range. for example srv1-3 will converted to [srv1, srv2, srv3]
Types ¶
type BalancingMethod ¶ added in v0.2.2
type BalancingMethod interface { FindServer(ip string, p []Server) (*Server, error) Rebalance([]Server) }
interface for balancing methods
func NewBalancingMethod ¶ added in v0.2.2
func NewBalancingMethod(name string) (BalancingMethod, error)
return new balancing method
type Filter ¶
type Filter struct { Name string // contains filtered or unexported fields }
contains ip filters
func (*Filter) Rebalance ¶ added in v0.2.4
func (f *Filter) Rebalance()
server pool rebalance func shell
func (*Filter) SetBalancingMethod ¶ added in v0.2.2
server pool set balancing method func shell
func (*Filter) SetLogFile ¶ added in v0.2.2
server pool set log file func shell
type HashIP ¶ added in v0.2.2
type HashIP struct {
// contains filtered or unexported fields
}
func (*HashIP) FindServer ¶ added in v0.2.2
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 Pool ¶
the struct that keep clients addresses caontain IP addresses "192.168.0.1" and IP networks "192.168.0.0/24"
type Random ¶ added in v0.2.2
type Random struct {
// contains filtered or unexported fields
}
func (*Random) FindServer ¶ added in v0.2.2
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 string Broken bool Weight int Priority float64 Fails int MaxFails int CurrentConnectionsNumber int BreakTime int // contains filtered or unexported fields }
representation of the server
func NewServer ¶
create and return new server. recive server address or domain name, server weight, maximal fail number, and break time after maximal allowed fails
func (*Server) Connect ¶
connct to the server, recieve protokol and port, return conncetion (net.Conn) or error
func (*Server) ExchangeData ¶
create a data pipe between client and server connections. end when ends connection session
func (*Server) Fail ¶
func (s *Server) Fail()
increment server fails quantity. if server fails == max fails, server become broken
func (*Server) SetLogFile ¶ added in v0.2.2
setting server log file
type ServerPool ¶
type ServerPool struct { Name string Servers []Server Broken []Server BM BalancingMethod }
the struct that keep servers
func NewServerPool ¶
func NewServerPool(m map[string]interface{}) (*ServerPool, error)
create and return new ServerPool
func (*ServerPool) Add ¶
func (p *ServerPool) Add(serverNames string, config map[string]interface{}) error
add server in servers pool
func (*ServerPool) AddFromMap ¶
func (p *ServerPool) AddFromMap(m map[string]interface{}) error
add servers in servers pool from map
func (*ServerPool) FindServer ¶ added in v0.2.2
func (s *ServerPool) FindServer(ip string) (*Server, error)
find server in pool. for finding uses currnet balancing method
func (*ServerPool) Rebalance ¶ added in v0.2.2
func (s *ServerPool) Rebalance()
rebalance servers pool
func (*ServerPool) SetBalancingMethod ¶ added in v0.2.2
func (s *ServerPool) SetBalancingMethod(name string) error
set balancing method
func (*ServerPool) SetConfig ¶
func (p *ServerPool) SetConfig(weight, maxFails, breakTime string) error
set new config to all servers in pool
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()
if server is broken - it move to array of broken server. if server returns to work - it move to array of working servers