iface

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxStreamBufferCap     int = 64 << 10
	IovMax                 int = 1024
	MaxTasks               int = 256
	DefaultWritevChunkSize int = 2048
	DefaultGoroutineSize   int = 1024
	DefaultErrInfoChanSize int = DefaultGoroutineSize
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AsyncCallback

type AsyncCallback func(c net.Conn) error

type AsyncWriteHook

type AsyncWriteHook struct {
	Go   AsyncCallback
	Data []byte
}

type AsyncWritevHook

type AsyncWritevHook struct {
	Go   AsyncCallback
	Data [][]byte
}

type Balancer

type Balancer int
const (
	RoundRobinLB Balancer = 0
	LeastConnLB  Balancer = 1
)

type BalancerIterFunc

type BalancerIterFunc func(key int, val IELoop) bool

type ConnAdapter

type ConnAdapter int
const (
	ConnAsyncWriteAdapter  ConnAdapter = 0
	ConnNoneAdapter        ConnAdapter = 1
	ConnWritevAdapter      ConnAdapter = 2
	ConnAsyncWritevAdapter ConnAdapter = 3
)

type Context

type Context struct {
	Reader     *bufio.Reader
	ReadWriter *bufio.ReadWriter
	RawConn    RawConn
	Conn       net.Conn
}

func (*Context) Read

func (that *Context) Read(data []byte) (int, error)

func (*Context) Write

func (that *Context) Write(data []byte) (int, error)

type IBalancer

type IBalancer interface {
	Register(IELoop)
	Next(addr ...net.Addr) IELoop
	Iterator(f BalancerIterFunc)
	Len() int
}

type IELoop

type IELoop interface {
	AddConnCount(i int32) int32
	RemoveConn(fd int)
	GetConnList() map[int]net.Conn
	GetConnCount() int32
	GetPoller() IPoller
	StartAsMainLoop(l bool)
	StartAsSubLoop(l bool)
}

type IEngine

type IEngine interface {
	GetOptions() *Options
	GetBalancer() IBalancer
	GetHandler() IEventHandler
}

type IEventHandler

type IEventHandler interface {
	OnAccept(Conn RawConn) error
	OnOpen(*Context) (data []byte, err error)
	OnTrack(*Context) error
	OnClose(*Context) error
}

type IFd

type IFd interface {
	GetFd() int
}

type IListener

type IListener interface {
	net.Listener
	IFd
	File() (*os.File, error)
	IsUDP() bool
}

type IPollCallback

type IPollCallback interface {
	Callback(fd int, events uint32) error
	AsyncCallback(fd int, events uint32) chan error
	AsyncWaitCallback(fd int, events uint32, wg *sync.WaitGroup) (errChan chan error)
	IsBlocked() bool
}

type IPoller

type IPoller interface {
	Close() error
	AddPriorTask(f PollTaskFunc, arg PollTaskArg) (err error)
}

type Options

type Options struct {
	NumOfLoops        int
	LoadBalancer      Balancer
	ReuseAddr         bool
	ReusePort         bool
	SocketWriteBuffer int
	SocketReadBuffer  int
	WriteBuffer       int
	ReadBuffer        int
	ConnKeepAlive     time.Duration
	LockOSThread      bool
	TLSConfig         *tls.Config
	ConnAdapter       ConnAdapter
	ConnAsyncCallback AsyncCallback
	WritevChunkSize   int
	GoroutineSize     int
}

type PollTaskArg

type PollTaskArg interface{}

type PollTaskFunc

type PollTaskFunc func(arg PollTaskArg) error

type RawConn

type RawConn interface {
	sys.EventHandler
}

Jump to

Keyboard shortcuts

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