tcpserver

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CRLFByte = byte('\n')

Functions

This section is empty.

Types

type Action

type Action = gnet.Action

type BuiltInFrameCodec

type BuiltInFrameCodec struct {
}

func (*BuiltInFrameCodec) Decode

func (cc *BuiltInFrameCodec) Decode(c Conn) ([]byte, error)

func (*BuiltInFrameCodec) Encode

func (cc *BuiltInFrameCodec) Encode(c Conn, buf []byte) ([]byte, error)

type Conn

type Conn = gnet.Conn

type DecoderConfig

type DecoderConfig struct {
	ByteOrder           binary.ByteOrder
	LengthFieldOffset   int
	LengthFieldLength   int
	LengthAdjustment    int
	InitialBytesToStrip int
}

type DelimiterBasedFrameCodec

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

func NewDelimiterBasedFrameCodec

func NewDelimiterBasedFrameCodec(delimiter byte) *DelimiterBasedFrameCodec

func (*DelimiterBasedFrameCodec) Decode

func (cc *DelimiterBasedFrameCodec) Decode(c Conn) ([]byte, error)

func (*DelimiterBasedFrameCodec) Encode

func (cc *DelimiterBasedFrameCodec) Encode(c Conn, buf []byte) ([]byte, error)

type EncoderConfig

type EncoderConfig struct {
	ByteOrder                       binary.ByteOrder
	LengthFieldLength               int
	LengthAdjustment                int
	LengthIncludesLengthFieldLength bool
}

type EventService

type EventService interface {
	OnInitComplete(server Server) (action Action)

	OnShutdown(server Server)

	OnOpened(c Conn) (out []byte, action Action)

	OnClosed(c Conn, err error) (action Action)

	PreWrite()

	React(frame []byte, c Conn) (out []byte, action Action)

	Tick() (delay time.Duration, action Action)
}

type FixedLengthFrameCodec

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

func NewFixedLengthFrameCodec

func NewFixedLengthFrameCodec(frameLength int) *FixedLengthFrameCodec

func (*FixedLengthFrameCodec) Decode

func (cc *FixedLengthFrameCodec) Decode(c Conn) ([]byte, error)

func (*FixedLengthFrameCodec) Encode

func (cc *FixedLengthFrameCodec) Encode(c Conn, buf []byte) ([]byte, error)

type GoroutinePool

type GoroutinePool = goroutine.Pool

func Pool

func Pool() *GoroutinePool

type ICodec

type ICodec interface {
	Encode(c Conn, buf []byte) ([]byte, error)
	Decode(c Conn) ([]byte, error)
}

type LB

type LB = gnet.LoadBalancing

type LengthFieldBasedFrameCodec

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

func (*LengthFieldBasedFrameCodec) Decode

func (cc *LengthFieldBasedFrameCodec) Decode(c Conn) ([]byte, error)

func (*LengthFieldBasedFrameCodec) Encode

func (cc *LengthFieldBasedFrameCodec) Encode(c Conn, buf []byte) (out []byte, err error)

type LineBasedFrameCodec

type LineBasedFrameCodec struct {
}

func (*LineBasedFrameCodec) Decode

func (cc *LineBasedFrameCodec) Decode(c Conn) ([]byte, error)

func (*LineBasedFrameCodec) Encode

func (cc *LineBasedFrameCodec) Encode(c Conn, buf []byte) ([]byte, error)

type Option

type Option func(*TcpServer)

func Addr

func Addr(addr string) Option

func Codec

func Codec(codec ICodec) Option

func LoadBalancing

func LoadBalancing(lb LB) Option

func LockOSThread

func LockOSThread(lockOSThread bool) Option

func Multicore

func Multicore(multicore bool) Option

func NumEventLoop

func NumEventLoop(numEventLoop int) Option

func ReusePort

func ReusePort(reusePort bool) Option

func TCPKeepAlive

func TCPKeepAlive(tcpKeepAlive time.Duration) Option

func Ticker

func Ticker(ticker bool) Option

type Server

type Server = gnet.Server

type Service

type Service struct {
	*gnet.EventServer

	Pool *GoroutinePool
	// contains filtered or unexported fields
}

func (*Service) Logger

func (s *Service) Logger() *log.ZapLogger

type TcpServer

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

func New

func New(opts ...Option) *TcpServer

func (*TcpServer) Run

func (s *TcpServer) Run()

func (*TcpServer) Serve

func (s *TcpServer) Serve(handler EventService, withPool bool)

Jump to

Keyboard shortcuts

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