gnet

package module
v0.0.0-...-42799e3 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

func NewClient(ctx *gonet.Context, options ...Option) gonet.IClient

func NewServer

func NewServer(ctx *gonet.Context, options ...Option) gonet.IServer

func SessionType

func SessionType() reflect.Type

Types

type LoadBalancing

type LoadBalancing int

LoadBalancing represents the type of load-balancing algorithm.

const (
	// RoundRobin assigns the next accepted connection to the event-loop by polling event-loop list.
	RoundRobin LoadBalancing = iota

	// LeastConnections assigns the next accepted connection to the event-loop that is
	// serving the least number of active connections at the current time.
	LeastConnections

	// SourceAddrHash assigns the next accepted connection to the event-loop by hashing the remote address.
	SourceAddrHash
)

type Option

type Option func(*option)

func WithLoadBalancing

func WithLoadBalancing(lb LoadBalancing) Option

WithLoadBalancing sets up the load-balancing algorithm in gnet engine.

func WithLockOSThread

func WithLockOSThread(lockOSThread bool) Option

WithLockOSThread sets up LockOSThread mode for I/O event-loops.

func WithMulticastInterfaceIndex

func WithMulticastInterfaceIndex(idx int) Option

WithMulticastInterfaceIndex sets the interface name where UDP multicast sockets will be bound to.

func WithMulticore

func WithMulticore(multicore bool) Option

WithMulticore sets up multi-cores in gnet engine.

func WithNumEventLoop

func WithNumEventLoop(numEventLoop int) Option

WithNumEventLoop sets up NumEventLoop in gnet engine.

func WithReadBufferCap

func WithReadBufferCap(readBufferCap int) Option

WithReadBufferCap sets up ReadBufferCap for reading bytes.

func WithReuseAddr

func WithReuseAddr(reuseAddr bool) Option

WithReuseAddr sets up SO_REUSEADDR socket option.

func WithReusePort

func WithReusePort(reusePort bool) Option

WithReusePort sets up SO_REUSEPORT socket option.

func WithSocketRecvBuffer

func WithSocketRecvBuffer(recvBuf int) Option

WithSocketRecvBuffer sets the maximum socket receive buffer in bytes.

func WithSocketSendBuffer

func WithSocketSendBuffer(sendBuf int) Option

WithSocketSendBuffer sets the maximum socket send buffer in bytes.

func WithTCPKeepAlive

func WithTCPKeepAlive(tcpKeepAlive time.Duration) Option

WithTCPKeepAlive sets up the SO_KEEPALIVE socket option with duration.

func WithTCPNoDelay

func WithTCPNoDelay(tcpNoDelay TCPSocketOpt) Option

WithTCPNoDelay enable/disable the TCP_NODELAY socket option.

func WithTicker

func WithTicker(ticker bool) Option

WithTicker indicates that a ticker is set.

func WithWriteBufferCap

func WithWriteBufferCap(writeBufferCap int) Option

WithWriteBufferCap sets up WriteBufferCap for pending bytes.

type TCPSocketOpt

type TCPSocketOpt int

TCPSocketOpt is the type of TCP socket options.

const (
	TCPNoDelay TCPSocketOpt = iota
	TCPDelay
)

Available TCP socket options.

Jump to

Keyboard shortcuts

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