network

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2022 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetID

func GetID(network, address string, seed int) string

func GetRLimit

func GetRLimit() syscall.Rlimit

Types

type Client

type Client struct {
	net.Conn

	ID                string
	ReceiveBufferSize int
	Network           string // tcp/udp/unix
	Address           string
}

func NewClient

func NewClient(network, address string, receiveBufferSize int) *Client

func (Client) Close

func (c Client) Close()

func (Client) Receive

func (c Client) Receive() (int, []byte, error)

func (Client) Send

func (c Client) Send(data []byte) error

type Pool

type Pool interface {
	ForEach(callback func(client *Client) error)
	Pool() sync.Map
	ClientIDs() []string
	Put(client *Client) error
	Pop(ID string) *Client
	Size() int
	Close() error
	Shutdown()
}

type PoolImpl

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

func NewPool

func NewPool() *PoolImpl

func (*PoolImpl) ClientIDs

func (p *PoolImpl) ClientIDs() []string

func (*PoolImpl) Close

func (p *PoolImpl) Close() error

func (*PoolImpl) ForEach

func (p *PoolImpl) ForEach(callback func(client *Client) error)

func (*PoolImpl) Pool

func (p *PoolImpl) Pool() sync.Map

func (*PoolImpl) Pop

func (p *PoolImpl) Pop(ID string) *Client

func (*PoolImpl) Put

func (p *PoolImpl) Put(client *Client) error

func (*PoolImpl) Shutdown

func (p *PoolImpl) Shutdown()

func (*PoolImpl) Size

func (p *PoolImpl) Size() int

type Proxy

type Proxy interface {
	Connect(c gnet.Conn) error
	Disconnect(c gnet.Conn) error
	PassThrough(c gnet.Conn) error
	Reconnect(cl *Client) *Client
	Shutdown()
	Size() int
}

type ProxyImpl

type ProxyImpl struct {
	PoolSize            int
	Elastic             bool
	ReuseElasticClients bool
	// contains filtered or unexported fields
}

func NewProxy

func NewProxy(size int, elastic, reuseElasticClients bool) *ProxyImpl

func (*ProxyImpl) Connect

func (pr *ProxyImpl) Connect(c gnet.Conn) error

func (*ProxyImpl) Disconnect

func (pr *ProxyImpl) Disconnect(c gnet.Conn) error

func (*ProxyImpl) PassThrough

func (pr *ProxyImpl) PassThrough(c gnet.Conn) error

func (*ProxyImpl) Reconnect

func (pr *ProxyImpl) Reconnect(cl *Client) *Client

func (*ProxyImpl) Shutdown

func (pr *ProxyImpl) Shutdown()

func (*ProxyImpl) Size

func (pr *ProxyImpl) Size() int

type Server

type Server struct {
	gnet.BuiltinEventEngine

	Network   string // tcp/udp/unix
	Address   string
	Options   []gnet.Option
	SoftLimit int
	HardLimit int
	// contains filtered or unexported fields
}

func (*Server) OnBoot

func (s *Server) OnBoot(engine gnet.Engine) gnet.Action

func (*Server) OnClose

func (s *Server) OnClose(c gnet.Conn, err error) (action gnet.Action)

func (*Server) OnOpen

func (s *Server) OnOpen(c gnet.Conn) (out []byte, action gnet.Action)

func (*Server) OnShutdown

func (s *Server) OnShutdown(engine gnet.Engine)

func (*Server) OnTick

func (s *Server) OnTick() (delay time.Duration, action gnet.Action)

func (*Server) OnTraffic

func (s *Server) OnTraffic(c gnet.Conn) gnet.Action

func (*Server) Run

func (s *Server) Run()

func (*Server) Shutdown

func (s *Server) Shutdown()

Jump to

Keyboard shortcuts

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