Documentation
¶
Index ¶
- Constants
- Variables
- func AlignedMem(size int) []byte
- func AlignedMemBlock() []byte
- func AlignedMemBlocks(n int) (blocks [][]byte)
- func ContextUserdata[T any](ctx context.Context) (ret T)
- func ContextWithUserdata[T any](parent context.Context, userdata T) context.Context
- func GetFd(x any) int
- func IP4AddressToBytes(ip net.IP) [4]byte
- func IP6AddressToBytes(ip net.IP) [16]byte
- func ListenAndServe(network string, address string, handler AcceptedHandler) error
- func MemoryBarrier()
- func NewMessagePipe(opts ...func(options *MessageOptions)) (reader io.Reader, writer io.Writer)
- func NewMessageReadWriter(reader io.Reader, writer io.Writer, opts ...func(options *MessageOptions)) io.ReadWriter
- func NewMessageReader(reader io.Reader, opts ...func(options *MessageOptions)) io.Reader
- func NewMessageWriter(writer io.Writer, opts ...func(options *MessageOptions)) io.Writer
- func NewRingQueue[ItemType any](opts ...func(options *RingQueueOptions)) (consumer ItemConsumer[ItemType], producer ItemProducer[ItemType], err error)
- func Serve(listener Listener, handler AcceptedHandler) error
- func Yield(ticks ...int)
- type AcceptedHandler
- type Addr
- type AddrError
- type BoundedPool
- func (pool *BoundedPool[T]) Cap() int
- func (pool *BoundedPool[T]) Fill(newFunc func() T)
- func (pool *BoundedPool[T]) Get() (indirect int, err error)
- func (pool *BoundedPool[T]) Put(indirect int) error
- func (pool *BoundedPool[T]) SetNonblock(nonblocking bool)
- func (pool *BoundedPool[T]) SetValue(indirect int, value T)
- func (pool *BoundedPool[T]) Value(indirect int) T
- type BoundedPoolItem
- type BufferType
- type Buffers
- type ClosedHandler
- type Conn
- func Dial(network string, address string) (conn Conn, err error)
- func NewSCTPConn(localAddr Addr, remoteSock *SCTPSocket) (Conn, error)
- func NewTCPConn(localAddr Addr, remoteSock *TCPSocket) (Conn, error)
- func NewUDPConn(localAddr Addr, remoteSock *UDPSocket) (Conn, error)
- func NewUnixConn(localAddr Addr, remoteSock *UnixSocket) (Conn, error)
- type ConnectedHandler
- type DispatchHandler
- type Empty
- type FixedStackOptions
- type GiantBuffer
- type GiantBufferBoundedPool
- type GiantBufferPool
- type HugeBuffer
- type HugeBufferBoundedPool
- type HugeBufferPool
- type IP
- type IPAddr
- type IndirectPool
- type Interface
- type InvalidAddrError
- type ItemConsumer
- type ItemProducer
- type LargeBuffer
- type LargeBufferBoundedPool
- type LargeBufferPool
- type Listener
- type ListenerSocket
- type MediumBuffer
- type MediumBufferBoundedPool
- type MediumBufferPool
- type MessageHandler
- type MessageOptions
- type MicroBuffer
- type MicroBufferBoundedPool
- type MicroBufferPool
- type NanoBuffer
- type NanoBufferBoundedPool
- type NanoBufferPool
- type NetworkType
- type OpError
- type OpcodePacketReader
- type OpcodePacketWriter
- type Options
- type PacketReader
- type PacketWriter
- type ParamSpinWait
- func (sw *ParamSpinWait) Closed() bool
- func (sw *ParamSpinWait) Once()
- func (sw *ParamSpinWait) OnceWithLevel(level int)
- func (sw *ParamSpinWait) Reset()
- func (sw *ParamSpinWait) SetLevel(level int) *ParamSpinWait
- func (sw *ParamSpinWait) SetLimit(limit int) *ParamSpinWait
- func (sw *ParamSpinWait) WillYield() bool
- func (sw *ParamSpinWait) WillYieldWithLevel(level int8) bool
- type PicoBuffer
- type PicoBufferBoundedPool
- type PicoBufferPool
- type PollCloser
- type PollFd
- type PollReadCloser
- type PollReadWriteCloser
- type PollReadWriter
- type PollReader
- type PollSignalfd
- type PollUintReadCloser
- type PollUintReadWriteCloser
- type PollUintReadWriter
- type PollUintReader
- type PollUintWriteCloser
- type PollUintWriter
- type PollWriteCloser
- type PollWriter
- type Pool
- type RawConn
- func (so RawConn) Accept() (Socket, error)
- func (so RawConn) Close() error
- func (so RawConn) Connect(addr Addr) error
- func (so RawConn) Fd() int
- func (conn *RawConn) LocalAddr() Addr
- func (so RawConn) NetworkType() NetworkType
- func (conn *RawConn) Read(p []byte) (n int, err error)
- func (so RawConn) Readv(iovs [][]byte) (n int, err error)
- func (so RawConn) Recvmsg(buffers [][]byte, oob []byte) (n, oobn int, recvflags int, from Sockaddr, err error)
- func (conn *RawConn) RemoteAddr() Addr
- func (so RawConn) Sendmsg(buffers [][]byte, oob []byte, to Addr) (n int, err error)
- func (conn *RawConn) SetDeadline(t time.Time) error
- func (conn *RawConn) SetReadDeadline(t time.Time) error
- func (conn *RawConn) SetWriteDeadline(t time.Time) error
- func (conn *RawConn) Write(p []byte) (n int, err error)
- func (so RawConn) Writev(iovs [][]byte) (n int, err error)
- type RawSocket
- func (so RawSocket) Accept() (Socket, error)
- func (so RawSocket) Close() error
- func (so RawSocket) Connect(addr Addr) error
- func (so RawSocket) Fd() int
- func (so RawSocket) NetworkType() NetworkType
- func (so *RawSocket) Protocol() UnderlyingProtocol
- func (so RawSocket) Read(b []byte) (n int, err error)
- func (so RawSocket) Readv(iovs [][]byte) (n int, err error)
- func (so *RawSocket) RecvFrom(b []byte) (n int, addr Addr, err error)
- func (so RawSocket) Recvmsg(buffers [][]byte, oob []byte) (n, oobn int, recvflags int, from Sockaddr, err error)
- func (so *RawSocket) SendTo(b []byte, raddr Addr) (n int, err error)
- func (so RawSocket) Sendmsg(buffers [][]byte, oob []byte, to Addr) (n int, err error)
- func (so RawSocket) Write(b []byte) (n int, err error)
- func (so RawSocket) Writev(iovs [][]byte) (n int, err error)
- type RegisterBuffer
- type RegisterBufferPool
- type RingQueueOptions
- type SCTPAddr
- type SCTPConn
- func (so SCTPConn) Accept() (Socket, error)
- func (so SCTPConn) Close() error
- func (so SCTPConn) Connect(addr Addr) error
- func (so SCTPConn) Fd() int
- func (conn *SCTPConn) LocalAddr() Addr
- func (so SCTPConn) NetworkType() NetworkType
- func (so SCTPConn) Read(b []byte) (n int, err error)
- func (so SCTPConn) Readv(iovs [][]byte) (n int, err error)
- func (so SCTPConn) Recvmsg(buffers [][]byte, oob []byte) (n, oobn int, recvflags int, from Sockaddr, err error)
- func (conn *SCTPConn) RemoteAddr() Addr
- func (so SCTPConn) Sendmsg(buffers [][]byte, oob []byte, to Addr) (n int, err error)
- func (conn *SCTPConn) SetDeadline(t time.Time) error
- func (conn *SCTPConn) SetReadDeadline(t time.Time) error
- func (conn *SCTPConn) SetWriteDeadline(t time.Time) error
- func (so SCTPConn) Write(b []byte) (n int, err error)
- func (so SCTPConn) Writev(iovs [][]byte) (n int, err error)
- type SCTPListener
- func (l *SCTPListener) Accept() (Conn, error)
- func (l *SCTPListener) Addr() Addr
- func (l *SCTPListener) Close() error
- func (so SCTPListener) Connect(addr Addr) error
- func (so SCTPListener) Fd() int
- func (so SCTPListener) NetworkType() NetworkType
- func (so SCTPListener) Read(b []byte) (n int, err error)
- func (so SCTPListener) Readv(iovs [][]byte) (n int, err error)
- func (so SCTPListener) Recvmsg(buffers [][]byte, oob []byte) (n, oobn int, recvflags int, from Sockaddr, err error)
- func (so SCTPListener) Sendmsg(buffers [][]byte, oob []byte, to Addr) (n int, err error)
- func (so SCTPListener) Write(b []byte) (n int, err error)
- func (so SCTPListener) Writev(iovs [][]byte) (n int, err error)
- type SCTPSocket
- func (so SCTPSocket) Accept() (Socket, error)
- func (so *SCTPSocket) Bind(addr ...*SCTPAddr) error
- func (so SCTPSocket) Close() error
- func (so SCTPSocket) Connect(addr Addr) error
- func (so SCTPSocket) Fd() int
- func (so SCTPSocket) NetworkType() NetworkType
- func (so *SCTPSocket) Protocol() UnderlyingProtocol
- func (so SCTPSocket) Read(b []byte) (n int, err error)
- func (so SCTPSocket) Readv(iovs [][]byte) (n int, err error)
- func (so SCTPSocket) Recvmsg(buffers [][]byte, oob []byte) (n, oobn int, recvflags int, from Sockaddr, err error)
- func (so SCTPSocket) Sendmsg(buffers [][]byte, oob []byte, to Addr) (n int, err error)
- func (so *SCTPSocket) Shutdown(how int) error
- func (so SCTPSocket) Write(b []byte) (n int, err error)
- func (so SCTPSocket) Writev(iovs [][]byte) (n int, err error)
- type SmallBuffer
- type SmallBufferBoundedPool
- type SmallBufferPool
- type Sockaddr
- type SockaddrInet4
- type SockaddrInet6
- type SockaddrUnix
- type Socket
- type SpinWait
- type Spinlock
- type Stack
- type TCPAddr
- type TCPConn
- func (so TCPConn) Accept() (Socket, error)
- func (so TCPConn) Close() error
- func (so TCPConn) Connect(addr Addr) error
- func (so TCPConn) Fd() int
- func (conn *TCPConn) LocalAddr() Addr
- func (so TCPConn) NetworkType() NetworkType
- func (so TCPConn) Read(b []byte) (n int, err error)
- func (so TCPConn) Readv(iovs [][]byte) (n int, err error)
- func (so TCPConn) Recvmsg(buffers [][]byte, oob []byte) (n, oobn int, recvflags int, from Sockaddr, err error)
- func (conn *TCPConn) RemoteAddr() Addr
- func (so TCPConn) Sendmsg(buffers [][]byte, oob []byte, to Addr) (n int, err error)
- func (conn *TCPConn) SetDeadline(t time.Time) error
- func (conn *TCPConn) SetReadDeadline(t time.Time) error
- func (conn *TCPConn) SetWriteDeadline(t time.Time) error
- func (so TCPConn) Write(b []byte) (n int, err error)
- func (so TCPConn) Writev(iovs [][]byte) (n int, err error)
- type TCPListener
- func (l *TCPListener) Accept() (Conn, error)
- func (l *TCPListener) Addr() Addr
- func (so TCPListener) Close() error
- func (so TCPListener) Connect(addr Addr) error
- func (so TCPListener) Fd() int
- func (so TCPListener) NetworkType() NetworkType
- func (so TCPListener) Read(b []byte) (n int, err error)
- func (so TCPListener) Readv(iovs [][]byte) (n int, err error)
- func (so TCPListener) Recvmsg(buffers [][]byte, oob []byte) (n, oobn int, recvflags int, from Sockaddr, err error)
- func (so TCPListener) Sendmsg(buffers [][]byte, oob []byte, to Addr) (n int, err error)
- func (so TCPListener) Write(b []byte) (n int, err error)
- func (so TCPListener) Writev(iovs [][]byte) (n int, err error)
- type TCPSocket
- func (so TCPSocket) Accept() (Socket, error)
- func (so TCPSocket) Close() error
- func (so TCPSocket) Connect(addr Addr) error
- func (so TCPSocket) Fd() int
- func (so TCPSocket) NetworkType() NetworkType
- func (so *TCPSocket) Protocol() UnderlyingProtocol
- func (so TCPSocket) Read(b []byte) (n int, err error)
- func (so TCPSocket) Readv(iovs [][]byte) (n int, err error)
- func (so TCPSocket) Recvmsg(buffers [][]byte, oob []byte) (n, oobn int, recvflags int, from Sockaddr, err error)
- func (so TCPSocket) Sendmsg(buffers [][]byte, oob []byte, to Addr) (n int, err error)
- func (so *TCPSocket) Shutdown(how int) error
- func (so TCPSocket) Write(b []byte) (n int, err error)
- func (so TCPSocket) Writev(iovs [][]byte) (n int, err error)
- type TickedHandler
- type Timer
- type UDPAddr
- type UDPConn
- func DialUDP4(laddr *UDPAddr, raddr *UDPAddr) (*UDPConn, error)
- func DialUDP6(laddr *UDPAddr, raddr *UDPAddr) (*UDPConn, error)
- func ListenUDP(network string, laddr *UDPAddr) (conn *UDPConn, err error)
- func ListenUDP4(laddr *UDPAddr) (*UDPConn, error)
- func ListenUDP6(laddr *UDPAddr) (*UDPConn, error)
- func (so UDPConn) Accept() (Socket, error)
- func (so UDPConn) Close() error
- func (so UDPConn) Connect(addr Addr) error
- func (so UDPConn) Fd() int
- func (conn *UDPConn) LocalAddr() Addr
- func (so UDPConn) NetworkType() NetworkType
- func (conn *UDPConn) Read(p []byte) (n int, err error)
- func (so UDPConn) Readv(iovs [][]byte) (n int, err error)
- func (so UDPConn) Recvmsg(buffers [][]byte, oob []byte) (n, oobn int, recvflags int, from Sockaddr, err error)
- func (conn *UDPConn) RemoteAddr() Addr
- func (so UDPConn) Sendmsg(buffers [][]byte, oob []byte, to Addr) (n int, err error)
- func (conn *UDPConn) SetDeadline(t time.Time) error
- func (conn *UDPConn) SetReadDeadline(t time.Time) error
- func (conn *UDPConn) SetWriteDeadline(t time.Time) error
- func (conn *UDPConn) Write(p []byte) (n int, err error)
- func (so UDPConn) Writev(iovs [][]byte) (n int, err error)
- type UDPSocket
- func (so UDPSocket) Accept() (Socket, error)
- func (so UDPSocket) Close() error
- func (so UDPSocket) Connect(addr Addr) error
- func (so *UDPSocket) Dial4(raddr *UDPAddr) (conn *UDPConn, err error)
- func (so *UDPSocket) Dial6(raddr *UDPAddr) (conn *UDPConn, err error)
- func (so UDPSocket) Fd() int
- func (so UDPSocket) NetworkType() NetworkType
- func (so *UDPSocket) Protocol() UnderlyingProtocol
- func (so UDPSocket) Read(b []byte) (n int, err error)
- func (so UDPSocket) Readv(iovs [][]byte) (n int, err error)
- func (so *UDPSocket) RecvFrom(b []byte) (n int, addr Addr, err error)
- func (so UDPSocket) Recvmsg(buffers [][]byte, oob []byte) (n, oobn int, recvflags int, from Sockaddr, err error)
- func (so *UDPSocket) SendTo(b []byte, raddr Addr) (n int, err error)
- func (so UDPSocket) Sendmsg(buffers [][]byte, oob []byte, to Addr) (n int, err error)
- func (so UDPSocket) Write(b []byte) (n int, err error)
- func (so UDPSocket) Writev(iovs [][]byte) (n int, err error)
- type UnderlyingProtocol
- type UnixAddr
- type UnixConn
- func (so UnixConn) Accept() (Socket, error)
- func (so UnixConn) Close() error
- func (so UnixConn) Connect(addr Addr) error
- func (so UnixConn) Fd() int
- func (conn *UnixConn) LocalAddr() Addr
- func (so UnixConn) NetworkType() NetworkType
- func (so UnixConn) Read(b []byte) (n int, err error)
- func (so UnixConn) Readv(iovs [][]byte) (n int, err error)
- func (so UnixConn) Recvmsg(buffers [][]byte, oob []byte) (n, oobn int, recvflags int, from Sockaddr, err error)
- func (conn *UnixConn) RemoteAddr() Addr
- func (so UnixConn) Sendmsg(buffers [][]byte, oob []byte, to Addr) (n int, err error)
- func (conn *UnixConn) SetDeadline(t time.Time) error
- func (conn *UnixConn) SetReadDeadline(t time.Time) error
- func (conn *UnixConn) SetWriteDeadline(t time.Time) error
- func (so UnixConn) Write(b []byte) (n int, err error)
- func (so UnixConn) Writev(iovs [][]byte) (n int, err error)
- type UnixListener
- func (l *UnixListener) Accept() (Conn, error)
- func (l *UnixListener) Addr() Addr
- func (l *UnixListener) Close() error
- func (so UnixListener) Connect(addr Addr) error
- func (so UnixListener) Fd() int
- func (so UnixListener) NetworkType() NetworkType
- func (so UnixListener) Read(b []byte) (n int, err error)
- func (so UnixListener) Readv(iovs [][]byte) (n int, err error)
- func (so UnixListener) Recvmsg(buffers [][]byte, oob []byte) (n, oobn int, recvflags int, from Sockaddr, err error)
- func (so UnixListener) Sendmsg(buffers [][]byte, oob []byte, to Addr) (n int, err error)
- func (so UnixListener) Write(b []byte) (n int, err error)
- func (so UnixListener) Writev(iovs [][]byte) (n int, err error)
- type UnixSocket
- func (so UnixSocket) Accept() (Socket, error)
- func (so UnixSocket) Close() error
- func (so UnixSocket) Connect(addr Addr) error
- func (so UnixSocket) Fd() int
- func (so UnixSocket) NetworkType() NetworkType
- func (so *UnixSocket) Protocol() UnderlyingProtocol
- func (so UnixSocket) Read(b []byte) (n int, err error)
- func (so UnixSocket) Readv(iovs [][]byte) (n int, err error)
- func (so UnixSocket) Recvmsg(buffers [][]byte, oob []byte) (n, oobn int, recvflags int, from Sockaddr, err error)
- func (so UnixSocket) Sendmsg(buffers [][]byte, oob []byte, to Addr) (n int, err error)
- func (so *UnixSocket) Shutdown(how int) error
- func (so UnixSocket) Write(b []byte) (n int, err error)
- func (so UnixSocket) Writev(iovs [][]byte) (n int, err error)
- type UnknownNetworkError
- type Uring
- func (ur *Uring) Accept(ctx context.Context, listener Socket, options ...UringOpOptionFunc) error
- func (ur *Uring) AsyncCancel(ctx context.Context, userdata *ioUringCtx, options ...UringOpOptionFunc) error
- func (ur *Uring) Bind(ctx context.Context, so Socket, addr Addr, options ...UringOpOptionFunc) error
- func (ur *Uring) Close(ctx context.Context, file PollCloser, options ...UringOpOptionFunc) error
- func (ur *Uring) Connect(ctx context.Context, so Socket, remote Addr, options ...UringOpOptionFunc) error
- func (ur *Uring) Fallocate(ctx context.Context, fd int, mode uint32, offset int64, length int64, ...) error
- func (ur *Uring) FileAdvise(ctx context.Context, fd int, offset int64, length int, advice int, ...) error
- func (ur *Uring) LinkTimeout(ctx context.Context, d time.Duration, options ...UringOpOptionFunc) error
- func (ur *Uring) Listen(ctx context.Context, so Socket, options ...UringOpOptionFunc) error
- func (ur *Uring) Nop(ctx context.Context, options ...UringOpOptionFunc) error
- func (ur *Uring) OpenAt(ctx context.Context, dirfd int, pathname string, flags int, mode uint32, ...) error
- func (ur *Uring) PollAdd(ctx context.Context, fd int, events int, options ...UringOpOptionFunc) error
- func (ur *Uring) PollRemove(ctx context.Context, options ...UringOpOptionFunc) error
- func (ur *Uring) Read(ctx context.Context, fd int, b []byte, options ...UringOpOptionFunc) error
- func (ur *Uring) ReadFixed(ctx context.Context, fd int, bufIndex int, options ...UringOpOptionFunc) ([]byte, error)
- func (ur *Uring) ReadV(ctx context.Context, fd int, iovs [][]byte, options ...UringOpOptionFunc) error
- func (ur *Uring) Receive(ctx context.Context, so Socket, b []byte, options ...UringOpOptionFunc) error
- func (ur *Uring) RecvMsg(ctx context.Context, so PollFd, buffers [][]byte, oob []byte, ...) error
- func (ur *Uring) SCTP4Socket(ctx context.Context, options ...UringOpOptionFunc) error
- func (ur *Uring) SCTP6Socket(ctx context.Context, options ...UringOpOptionFunc) error
- func (ur *Uring) Send(ctx context.Context, so Socket, p []byte, options ...UringOpOptionFunc) error
- func (ur *Uring) SendMsg(ctx context.Context, so PollFd, buffers [][]byte, oob []byte, to Addr, ...) error
- func (ur *Uring) Shutdown(ctx context.Context, so Socket, how int, options ...UringOpOptionFunc) error
- func (ur *Uring) Socket(ctx context.Context, network, address string, options ...UringOpOptionFunc) error
- func (ur *Uring) SocketRaw(ctx context.Context, domain, typ, proto int, options ...UringOpOptionFunc) error
- func (ur *Uring) Splice(ctx context.Context, fdIn, fdOut int, len int, options ...UringOpOptionFunc) error
- func (ur *Uring) Start(ctx context.Context) error
- func (ur *Uring) Sync(ctx context.Context, fd int, options ...UringOpOptionFunc) error
- func (ur *Uring) SyncFileRange(ctx context.Context, fd int, offset int64, length int, flags int, ...) error
- func (ur *Uring) TCP4Socket(ctx context.Context, options ...UringOpOptionFunc) error
- func (ur *Uring) TCP6Socket(ctx context.Context, options ...UringOpOptionFunc) error
- func (ur *Uring) Tee(ctx context.Context, fdIn, fdOut int, length int, options ...UringOpOptionFunc) error
- func (ur *Uring) Timeout(ctx context.Context, d time.Duration, options ...UringOpOptionFunc) error
- func (ur *Uring) TimeoutRemove(ctx context.Context, userData unsafe.Pointer, options ...UringOpOptionFunc) error
- func (ur *Uring) UDP4Socket(ctx context.Context, options ...UringOpOptionFunc) error
- func (ur *Uring) UDP6Socket(ctx context.Context, options ...UringOpOptionFunc) error
- func (ur *Uring) UDPLITE4Socket(ctx context.Context, options ...UringOpOptionFunc) error
- func (ur *Uring) UDPLITE6Socket(ctx context.Context, options ...UringOpOptionFunc) error
- func (ur *Uring) UnixSocket(ctx context.Context, options ...UringOpOptionFunc) error
- func (ur *Uring) Wait(events []*UringEvent) (n int, err error)
- func (ur *Uring) Write(ctx context.Context, fd int, b []byte, n int, options ...UringOpOptionFunc) error
- func (ur *Uring) WriteFixed(ctx context.Context, fd int, bufIndex int, n int, options ...UringOpOptionFunc) error
- func (ur *Uring) WriteV(ctx context.Context, fd int, iovs [][]byte, options ...UringOpOptionFunc) error
- type UringEvent
- type UringEventData
- type UringFeatures
- type UringOpOption
- type UringOpOptionFunc
- type UringOptionFunc
- type UringOptions
- type WrittenHandler
Constants ¶
const ( // BoundedPoolPicoCapacity is the recommended capacity for PicoBufferBoundedPool BoundedPoolPicoCapacity // BoundedPoolNanoCapacity is the recommended capacity for NanoBufferBoundedPool BoundedPoolNanoCapacity // BoundedPoolMicroCapacity is the recommended capacity for MicroBufferBoundedPool BoundedPoolMicroCapacity // BoundedPoolSmallCapacity is the recommended capacity for SmallBufferBoundedPool BoundedPoolSmallCapacity // BoundedPoolMediumCapacity is the recommended capacity for MediumBufferBoundedPool BoundedPoolMediumCapacity // BoundedPoolLargeCapacity is the recommended capacity for LargeBufferBoundedPool BoundedPoolLargeCapacity // BoundedPoolHugeCapacity is the recommended capacity for HugeBufferBoundedPool BoundedPoolHugeCapacity // BoundedPoolGiantCapacity is the recommended capacity for GiantBufferBoundedPool BoundedPoolGiantCapacity )
const ( // BufferSizePico represents the size of a pico buffer BufferSizePico // BufferSizeNano represents the size of a nano buffer. BufferSizeNano // BufferSizeMicro represents the size of a micro buffer. BufferSizeMicro // BufferSizeSmall represents the size of a small buffer. BufferSizeSmall // BufferSizeMedium represents the size of a medium buffer. BufferSizeMedium // BufferSizeLarge represents the size of a large buffer. BufferSizeLarge // BufferSizeHuge represents the size of a huge buffer. BufferSizeHuge // BufferSizeGiant represents the size of a giant buffer. BufferSizeGiant )
const ( // OpcodeTextMessage denotes a text message OpcodeTextMessage = 1 << 4 // OpcodeBinaryMessage denotes a binary message OpcodeBinaryMessage = 2 << 4 // OpcodeBuiltinCommand denotes a builtin-command message with 4-bits command code OpcodeBuiltinCommand = 4 << 4 // OpcodeExtBuiltinCommand denotes a builtin-command message with 1-byte command code OpcodeExtBuiltinCommand = 5 << 4 // OpcodeClose denotes a connection close OpcodeClose = 8 << 4 // OpcodePing denotes a ping OpcodePing = 9 << 4 // OpcodePong denotes a pong OpcodePong = 10 << 4 )
const ( SCTP_RTOINFO = 0 SCTP_ASSOCINFO = 1 SCTP_INITMSG = 2 SCTP_NODELAY = 3 SCTP_SOCKOPT_BINDX_ADD = 100 SCTP_SOCKOPT_BINDX_REM = 101 SCTP_SOCKOPT_CONNECTX = 110 SCTP_SOCKOPT_CONNECTX3 = 111 )
const ( // SockShutdownRead is a constant that represents the action of shutting down // the reading side of a socket. It is used in conjunction with the unix.SHUT_RD // constant to specify the shutdown action. SockShutdownRead = unix.SHUT_RD // SockShutdownWrite represents a constant that is used to shutdown the write // function of a socket. It is typically used with the SockShutdown function // in the unix package. SockShutdownWrite = unix.SHUT_WR // SockShutdownReadWrite is a constant that represents the value `unix.SHUT_RDWR`. // It can be used to specify shutting down both the reading and writing operations // of a socket. SockShutdownReadWrite = unix.SHUT_RDWR )
const ( // SpinWaitLevelBlocking results in less CPU consumption but may cause a little delay // It is suggested to be used for io events polling etc. SpinWaitLevelBlocking = iota // SpinWaitLevelPending take balances of CPU consumption and delay // It is often to be used for producer-consumer ops on concurrent data structures SpinWaitLevelPending // SpinWaitLevelPreempting results in higher CPU consumption and lower delay, // which makes it suitable for time-sensitive operations on concurrent data structures. SpinWaitLevelPreempting )
const ( DefaultTimerID = 0 DefaultTimerHZ = 60 )
const ( IORING_SETUP_IOPOLL = 1 << 0 IORING_SETUP_SQPOLL = 1 << 1 IORING_SETUP_SQ_AFF = 1 << 2 IORING_SETUP_CQSIZE = 1 << 3 IORING_SETUP_CLAMP = 1 << 4 IORING_SETUP_ATTACH_WQ = 1 << 5 IORING_SETUP_R_DISABLED = 1 << 6 IORING_SETUP_SUBMIT_ALL = 1 << 7 IORING_SETUP_COOP_TASKRUN = 1 << 8 IORING_SETUP_TASKRUN_FLAG = 1 << 9 IORING_SETUP_SQE128 = 1 << 10 IORING_SETUP_CQE32 = 1 << 11 IORING_SETUP_SINGLE_ISSUER = 1 << 12 IORING_SETUP_DEFER_TASKRUN = 1 << 13 IORING_SETUP_NO_MMAP = 1 << 14 IORING_SETUP_REGISTERED_FD_ONLY = 1 << 15 IORING_SETUP_NO_SQARRAY = 1 << 16 IORING_SETUP_HYBRID_IOPOLL = 1 << 17 )
const ( IORING_FEAT_SINGLE_MMAP = 1 << iota IORING_FEAT_NODROP IORING_FEAT_SUBMIT_STABLE IORING_FEAT_RW_CUR_POS IORING_FEAT_CUR_PERSONALITY IORING_FEAT_FAST_POLL IORING_FEAT_POLL_32BITS IORING_FEAT_SQPOLL_NONFIXED IORING_FEAT_EXT_ARG IORING_FEAT_NATIVE_WORKERS IORING_FEAT_RSRC_TAGS IORING_FEAT_CQE_SKIP IORING_FEAT_LINKED_FILE IORING_FEAT_REG_REG_RING )
const ( IORING_ENTER_GETEVENTS = 1 << 0 IORING_ENTER_SQ_WAKEUP = 1 << 1 IORING_ENTER_SQ_WAIT = 1 << 2 IORING_ENTER_EXT_ARG = 1 << 3 IORING_ENTER_REGISTERED_RING = 1 << 4 )
const ( IORING_OFF_SQ_RING int64 = 0 IORING_OFF_CQ_RING int64 = 0x8000000 IORING_OFF_SQES int64 = 0x10000000 IORING_OFF_PBUF_RING = 0x80000000 IORING_OFF_PBUF_SHIFT = 16 IORING_OFF_MMAP_MASK = 0xf8000000 )
const ( IORING_SQ_NEED_WAKEUP = 1 << iota IORING_SQ_CQ_OVERFLOW IORING_SQ_TASKRUN )
const ( IOSQE_FIXED_FILE = 1 << iota IOSQE_IO_DRAIN IOSQE_IO_LINK IOSQE_IO_HARDLINK IOSQE_ASYNC IOSQE_BUFFER_SELECT IOSQE_CQE_SKIP_SUCCESS )
const ( IORING_POLL_ADD_MULTI = 1 << iota IORING_POLL_UPDATE_EVENTS IORING_POLL_UPDATE_USER_DATA IORING_POLL_ADD_LEVEL )
const ( IORING_ASYNC_CANCEL_ALL = 1 << iota IORING_ASYNC_CANCEL_FD IORING_ASYNC_CANCEL_ANY IORING_ASYNC_CANCEL_FD_FIXED IORING_ASYNC_CANCEL_USERDATA IORING_ASYNC_CANCEL_OP )
const ( IORING_CQE_F_BUFFER = 1 << iota IORING_CQE_F_MORE IORING_CQE_F_SOCK_NONEMPTY IORING_CQE_F_NOTIF )
const ( IORING_REGISTER_BUFFERS uintptr = iota IORING_UNREGISTER_BUFFERS IORING_REGISTER_FILES IORING_UNREGISTER_FILES IORING_REGISTER_EVENTFD IORING_UNREGISTER_EVENTFD IORING_REGISTER_FILES_UPDATE IORING_REGISTER_EVENTFD_ASYNC IORING_REGISTER_PROBE IORING_REGISTER_PERSONALITY IORING_UNREGISTER_PERSONALITY IORING_REGISTER_RESTRICTIONS IORING_REGISTER_ENABLE_RINGS IORING_REGISTER_FILES2 IORING_REGISTER_FILES_UPDATE2 IORING_REGISTER_BUFFERS2 IORING_REGISTER_BUFFERS_UPDATE IORING_REGISTER_IOWQ_AFF IORING_UNREGISTER_IOWQ_AFF IORING_REGISTER_IOWQ_MAX_WORKERS IORING_REGISTER_RING_FDS IORING_UNREGISTER_RING_FDS IORING_REGISTER_PBUF_RING IORING_UNREGISTER_PBUF_RING IORING_REGISTER_SYNC_CANCEL IORING_REGISTER_FILE_ALLOC_RANGE IORING_REGISTER_PBUF_STATUS IORING_REGISTER_NAPI IORING_UNREGISTER_NAPI )
const ( UringEntriesPico UringEntriesNano UringEntriesMicro UringEntriesSmall UringEntriesMedium UringEntriesLarge UringEntriesHuge )
const ( IORING_OP_NOP uint8 = iota IORING_OP_READV IORING_OP_WRITEV IORING_OP_FSYNC IORING_OP_READ_FIXED IORING_OP_WRITE_FIXED IORING_OP_POLL_ADD IORING_OP_POLL_REMOVE IORING_OP_SYNC_FILE_RANGE IORING_OP_SENDMSG IORING_OP_RECVMSG IORING_OP_TIMEOUT IORING_OP_TIMEOUT_REMOVE IORING_OP_ACCEPT IORING_OP_ASYNC_CANCEL IORING_OP_LINK_TIMEOUT IORING_OP_CONNECT IORING_OP_FALLOCATE IORING_OP_OPENAT IORING_OP_CLOSE IORING_OP_FILES_UPDATE IORING_OP_STATX IORING_OP_READ IORING_OP_WRITE IORING_OP_FADVISE IORING_OP_MADVISE IORING_OP_SEND IORING_OP_RECV IORING_OP_OPENAT2 IORING_OP_EPOLL_CTL IORING_OP_SPLICE IORING_OP_PROVIDE_BUFFERS IORING_OP_REMOVE_BUFFERS IORING_OP_TEE IORING_OP_SHUTDOWN IORING_OP_RENAMEAT IORING_OP_UNLINKAT IORING_OP_MKDIRAT IORING_OP_SYMLINKAT IORING_OP_LINKAT IORING_OP_MSG_RING IORING_OP_FSETXATTR IORING_OP_SETXATTR IORING_OP_FGETXATTR IORING_OP_GETXATTR IORING_OP_SOCKET IORING_OP_URING_CMD IORING_OP_SEND_ZC IORING_OP_SENDMSG_ZC IORING_OP_READ_MULTISHOT IORING_OP_WAITID IORING_OP_FUTEX_WAIT IORING_OP_FUTEX_WAKE IORING_OP_FUTEX_WAITV IORING_OP_FIXED_FD_INSTALL IORING_OP_FTRUNCATE IORING_OP_BIND IORING_OP_LISTEN )
const ( IORING_TIMEOUT_ABS = 1 << iota IORING_TIMEOUT_UPDATE IORING_TIMEOUT_BOOTTIME IORING_TIMEOUT_REALTIME IORING_LINK_TIMEOUT_UPDATE IORING_TIMEOUT_ETIME_SUCCESS IORING_TIMEOUT_MULTISHOT IORING_TIMEOUT_CLOCK_MASK = IORING_TIMEOUT_BOOTTIME | IORING_TIMEOUT_REALTIME IORING_TIMEOUT_UPDATE_MASK = IORING_TIMEOUT_UPDATE | IORING_LINK_TIMEOUT_UPDATE )
const ( IORING_ACCEPT_MULTISHOT = 1 << 0 IORING_ACCEPT_DONTWAIT = 1 << 1 IORING_ACCEPT_POLL_FIRST = 1 << 2 )
const ( IORING_RECVSEND_POLL_FIRST = 1 << iota IORING_RECV_MULTISHOT IORING_RECVSEND_FIXED_BUF IORING_SEND_ZC_REPORT_USAGE IORING_RECVSEND_BUNDLE )
const (
IORING_CQE_BUFFER_SHIFT = 16
)
const (
IO_URING_OP_SUPPORTED = 1 << 0
)
const (
SOL_SCTP = 132
)
Variables ¶
var ( // IPV4zero is an IPv4 address representing the zero value (0.0.0.0). IPV4zero = net.IPv4zero // IPV6unspecified is an IPv6 address representing the unspecified value (::). IPV6unspecified = net.IPv6unspecified // IPv4LoopBack is an IPv4 address representing the loopback address (127.0.0.1). IPv4LoopBack = net.IPv4(127, 0, 0, 1) // IPv6LoopBack is an IPv6 address representing the loopback address (::). IPv6LoopBack = net.IPv6loopback )
var ( // TCPAddrFromAddrPort refers to the net.TCPAddrFromAddrPort function // It returns addr as a [TCPAddr]. If addr.IsValid() is false, // then the returned TCPAddr will contain a nil IP field, indicating an // address-family-agnostic unspecified address. TCPAddrFromAddrPort = net.TCPAddrFromAddrPort // UDPAddrFromAddrPort refers to the net.UDPAddrFromAddrPort function // It returns addr as a UDPAddr. If addr.IsValid() is false, // then the returned UDPAddr will contain a nil IP field, indicating an // address-family-agnostic unspecified address. UDPAddrFromAddrPort = net.UDPAddrFromAddrPort )
var ( // ResolveIPAddr refers to the net.ResolveIPAddr function // It returns an address of the IP end point. ResolveIPAddr = net.ResolveIPAddr // ResolveTCPAddr refers to the net.ResolveTCPAddr function. // It returns a TCPAddr struct that contains IP and port information. ResolveTCPAddr = net.ResolveTCPAddr // ResolveUDPAddr refers to the net.ResolveUDPAddr function. // It takes a network type and a string representation of the address and returns a // UDPAddr struct that contains the IP and port information. ResolveUDPAddr = net.ResolveUDPAddr )
var ( // ErrMsgInvalidArguments will be returned when got invalid parameter ErrMsgInvalidArguments = errors.New("message invalid argument") // ErrMsgInvalidRead will be returned when read operation invalid ErrMsgInvalidRead = errors.New("message invalid read result") // ErrMsgInvalidWrite will be returned when write operation invalid ErrMsgInvalidWrite = errors.New("message invalid write result") // ErrMsgTooLong will be returned when try to read or write a message which is too long ErrMsgTooLong = errors.New("message too long") // ErrMsgClosed will be returned when try to read or write on a closed reader or writer ErrMsgClosed = errors.New("message closed") )
var ( // ErrInterruptedSyscall represents an error indicating an interrupted system call. ErrInterruptedSyscall = errors.New("interrupted system call") // In many cases, when ErrTemporarilyUnavailable is returned, the caller would block. ErrTemporarilyUnavailable = errors.New("resource temporarily unavailable") // ErrInProgress represents an error indicating that an operation is in progress. ErrInProgress = errors.New("in progress") // ErrFaultParams represents an error indicating fault parameters. ErrFaultParams = errors.New("fault parameters") // ErrInvalidParam is an error indicating that a parameter passed to a function is invalid. ErrInvalidParam = errors.New("invalid param") // ErrProcessFileLimit represents an error indicating that the process has reached its open file descriptor limit. ErrProcessFileLimit = errors.New("process open fd limit") // ErrSystemFileLimit represents an error indicating that the system has reached its open file descriptor limit. ErrSystemFileLimit = errors.New("system open fd limit") // ErrNoDevice represents an error indicating that there is no device available. ErrNoDevice = errors.New("no device") // ErrNoAvailableMemory represents an error indicating that there is no available kernel memory. ErrNoAvailableMemory = errors.New("no available kernel memory") // ErrNoPermission represents an error indicating that the operation is not permitted. ErrNoPermission = errors.New("operation not permitted") // ErrCanceled represents an error indicating that an operation was canceled. ErrCanceled = errors.New("operation canceled") )
var ( // DefaultResolver is a variable that holds the default resolver implementation // for performing network resolution in the Go standard library. DefaultResolver = net.DefaultResolver )
var MessageOptionsNetworkOrder = func(options *MessageOptions) { options.ReadByteOrder = binary.BigEndian options.WriteByteOrder = binary.BigEndian }
MessageOptionsNetworkOrder sets byte order to big endian
var MessageOptionsNonblock = func(options *MessageOptions) { options.Nonblock = true }
MessageOptionsNonblock sets message nonblock
var MessageOptionsRawSocket = func(options *MessageOptions) { options.ReadByteOrder = binary.BigEndian options.WriteByteOrder = binary.BigEndian options.ReadProto = UnderlyingProtocolRaw options.WriteProto = UnderlyingProtocolRaw }
MessageOptionsRawSocket sets feature options for raw sockets
var MessageOptionsSCTPSocket = func(options *MessageOptions) { options.ReadByteOrder = binary.BigEndian options.WriteByteOrder = binary.BigEndian options.ReadProto = UnderlyingProtocolSeqPacket options.WriteProto = UnderlyingProtocolSeqPacket }
MessageOptionsSCTPSocket sets feature options for SCTP sockets
var MessageOptionsTCPSocket = func(options *MessageOptions) { options.ReadByteOrder = binary.BigEndian options.WriteByteOrder = binary.BigEndian options.ReadProto = UnderlyingProtocolStream options.WriteProto = UnderlyingProtocolStream }
MessageOptionsTCPSocket sets feature options for TCP sockets
var ( // NetworkByteOrder represents the network byte order, which is big-endian. NetworkByteOrder = binary.BigEndian )
var PageSize = uintptr(os.Getpagesize())
var ( // ResolveUnixAddr is a function that resolves a Unix network address. ResolveUnixAddr = net.ResolveUnixAddr )
Functions ¶
func AlignedMem ¶
AlignedMem returns a byte slice with the specified size and starting address aligned to the memory page size.
func AlignedMemBlocks ¶
AlignedMemBlocks returns n bytes slices that have length with memory page size and address starts from multiple of memory page size
func ContextUserdata ¶
func ContextWithUserdata ¶
func GetFd ¶
GetFd gets the file descriptor of a given object. It checks if the object implements the PollFd interface, and if so, returns the result of calling the Fd method on it. If the object implements the file interface, it retrieves the file using the File method and returns its file descriptor. If none of these conditions are met, it returns -1.
func IP4AddressToBytes ¶
IP4AddressToBytes converts an IPv4 address to a byte array. If the given IP address is not an IPv4 address, it returns an empty byte array. The byte array contains the four octets of the IPv4 address in network byte order.
func IP6AddressToBytes ¶
IP6AddressToBytes converts the given net.IPv6 address to a fixed-size byte array. The resulting byte array contains the individual bytes of the IPv6 address in the same order as the original address. Each byte of the byte array corresponds to a byte of the IPv6 address. For example, the first byte of the byte array corresponds to the first byte of the IPv6 address, and so on. The byte array has a length of 16 bytes.
Note: This function assumes that the given net.IPv6 address is a valid IPv6 address.
func ListenAndServe ¶
func ListenAndServe(network string, address string, handler AcceptedHandler) error
ListenAndServe listens on the given network and address, and then calls Serve method with the given handler to handle incoming connect requests
func MemoryBarrier ¶
func MemoryBarrier()
MemoryBarrier provides a memory barrier operation to ensure ordering of memory accesses.
func NewMessagePipe ¶
func NewMessagePipe(opts ...func(options *MessageOptions)) (reader io.Reader, writer io.Writer)
NewMessagePipe creates and returns a synchronous in-memory message pipe
func NewMessageReadWriter ¶
func NewMessageReadWriter(reader io.Reader, writer io.Writer, opts ...func(options *MessageOptions)) io.ReadWriter
NewMessageReadWriter creates and returns a new io.ReadWriter to read and write messages
func NewMessageReader ¶
func NewMessageReader(reader io.Reader, opts ...func(options *MessageOptions)) io.Reader
NewMessageReader creates and returns a new io.Reader to read messages
func NewMessageWriter ¶
func NewMessageWriter(writer io.Writer, opts ...func(options *MessageOptions)) io.Writer
NewMessageWriter creates and returns a new io.Writer to write messages
func NewRingQueue ¶
func NewRingQueue[ItemType any]( opts ...func(options *RingQueueOptions)) ( consumer ItemConsumer[ItemType], producer ItemProducer[ItemType], err error)
NewRingQueue creates a ring queue with given options and returns the consumer and the producer of it
func Serve ¶
func Serve(listener Listener, handler AcceptedHandler) error
Serve accepts and handles incoming connections on the listener l with the given handler Serve method works like this:
evLoop, _ = New() evLoop.AddAccepted(listener, handler) return evLoop.Serve()
Types ¶
type AcceptedHandler ¶
AcceptedHandler handles the listener accepted new connections event
type BoundedPool ¶
type BoundedPool[T BoundedPoolItem] struct { // contains filtered or unexported fields }
func NewBoundedPool ¶
func NewBoundedPool[ItemType BoundedPoolItem](capacity int) *BoundedPool[ItemType]
NewBoundedPool creates a new instance of BoundedPool with the specified capacity. The capacity must be between 1 and math.MaxUint32 (inclusive).
func (*BoundedPool[T]) Cap ¶
func (pool *BoundedPool[T]) Cap() int
Cap returns the capacity of the BoundedPool
func (*BoundedPool[T]) Fill ¶
func (pool *BoundedPool[T]) Fill(newFunc func() T)
Fill initializes and fills the BoundedPool with a newFunc function, which is used to create new items. Fill Put capacity items with new BoundedPoolItem created by newFunc for each item in the pool.
Example:
pool := NewBoundedPool[ItemType](capacity) pool.Fill(newFunc)
Parameters:
newFunc - a function that returns an instance of an item to be added to the pool.
func (*BoundedPool[T]) Get ¶
func (pool *BoundedPool[T]) Get() (indirect int, err error)
Get retrieves an item from the pool and returns its indirect index. If an item is available, its indirect index and a nil error are returned.
func (*BoundedPool[T]) Put ¶
func (pool *BoundedPool[T]) Put(indirect int) error
Put puts the indirect index of an item back into the BoundedPool. It tries to put the given indirect index into the pool and returns nil error if successful. If the BoundedPool is currently full, it would block until the item can be put into the pool or return an ErrTemporarilyUnavailable error if the pool is nonblocking.
func (*BoundedPool[T]) SetNonblock ¶
func (pool *BoundedPool[T]) SetNonblock(nonblocking bool)
SetNonblock enables or disables the non-blocking mode of the pool. When nonblocking is set to true, Get() and Put() calls will not block and return immediately. When nonblocking is set to false, Get() calls will block until an item is available, and Put() calls will block until the pool is no longer full.
Example:
pool := NewBoundedPool[ItemType](capacity) pool.SetNonblock(true)
Parameters:
nonblocking - determines whether the pool operates in non-blocking mode (true) or blocking mode (false).
func (*BoundedPool[T]) SetValue ¶
func (pool *BoundedPool[T]) SetValue(indirect int, value T)
SetValue sets the value of the item at the specified indirect index in the BoundedPool. The given indirect index must not be marked as empty and must be within the valid range.
func (*BoundedPool[T]) Value ¶
func (pool *BoundedPool[T]) Value(indirect int) T
Value returns the item at the specified indirect index. The given indirect index must not be marked as empty and must be within the valid range.
type BoundedPoolItem ¶
type BoundedPoolItem interface{}
BoundedPoolItem is an interface that represents an item that can be used in a bounded pool. Implementing this interface allows an object to be stored and retrieved from a BoundedPool.
type BufferType ¶
type BufferType interface {
PicoBuffer | NanoBuffer | MicroBuffer | SmallBuffer | MediumBuffer | LargeBuffer | HugeBuffer | GiantBuffer
}
BufferType is an interface that represents different types of buffers, including PicoBuffer, NanoBuffer, MicroBuffer, SmallBuffer, MediumBuffer, LargeBuffer, HugeBuffer, and GiantBuffer. Each buffer type is a byte array with a specific size.
type Buffers ¶
Buffers is an alias of net.Buffers
func NewBuffers ¶
NewBuffers creates and initializes a new Buffers with a given n and size
type ClosedHandler ¶
ClosedHandler handles connection closed event
type Conn ¶
Conn is an alias for net.Conn type. It represents a generic network connection. It has methods for accessing the local and remote addresses, setting deadlines, and shutting down the connection.
Conn is used in various examples and functions in the codebase. Some of the usage examples include: - NewTCPConn: creates a new TCP connection - NewUDPConn: creates a new UDP connection - NewSCTPConn: creates a new SCTP connection - NewUnixConn: creates a new Unix connection
func NewSCTPConn ¶
func NewSCTPConn(localAddr Addr, remoteSock *SCTPSocket) (Conn, error)
func NewUnixConn ¶
func NewUnixConn(localAddr Addr, remoteSock *UnixSocket) (Conn, error)
type ConnectedHandler ¶
type ConnectedHandler interface {
ServeConnected(conn Conn)
}
ConnectedHandler handles the client connected to remote server event
type DispatchHandler ¶
type DispatchHandler interface {
ServeDispatch(ctx context.Context, reader PollReader) MessageHandler
}
DispatchHandler chooses the MessageHandler which will be used to handle the incoming message
type FixedStackOptions ¶
type FixedStackOptions struct {
// Capacity specifies the capacity of Stack. The default Capacity is 32K
Capacity uint32
// Concurrent specifies whether the Stack works in Concurrent mode or not
// Concurrent should be set as true,
// if there are multiple goroutines doing Push or multiple goroutines doing Pop
Concurrent bool
// Nonblocking specifies whether the Push or Pop operations will NOT block
// even if it is temporarily unavailable or not
Nonblocking bool
}
FixedStackOptions holds optional parameters for Stack implementations
type GiantBuffer ¶
type GiantBuffer [BufferSizeGiant]byte
GiantBuffer represents a byte array with size of BufferSizeGiant
func NewGiantBuffer ¶
func NewGiantBuffer() GiantBuffer
NewGiantBuffer returns a new instance of GiantBuffer.
func (GiantBuffer) Reset ¶
func (b GiantBuffer) Reset()
type GiantBufferBoundedPool ¶
type GiantBufferBoundedPool = BoundedPool[GiantBuffer]
GiantBufferBoundedPool is a type alias of BoundedPool[GiantBuffer].
func NewGiantBufferPool ¶
func NewGiantBufferPool(capacity int) *GiantBufferBoundedPool
NewGiantBufferPool creates a new instance of GiantBufferBoundedPool with the specified capacity. The capacity must be between 1 and math.MaxUint32 and will be rounded up to the next power of two.
type GiantBufferPool ¶
type GiantBufferPool = IndirectPool[GiantBuffer]
GiantBufferPool represents a generic object pool that uses indirect indices to Put and Get items of type GiantBuffer
type HugeBuffer ¶
type HugeBuffer [BufferSizeHuge]byte
HugeBuffer represents a byte array with size of BufferSizeHuge
func NewHugeBuffer ¶
func NewHugeBuffer() HugeBuffer
NewHugeBuffer returns a new instance of HugeBuffer.
func (HugeBuffer) Reset ¶
func (b HugeBuffer) Reset()
type HugeBufferBoundedPool ¶
type HugeBufferBoundedPool = BoundedPool[HugeBuffer]
HugeBufferBoundedPool is a type alias of BoundedPool[HugeBuffer].
func NewHugeBufferPool ¶
func NewHugeBufferPool(capacity int) *HugeBufferBoundedPool
NewHugeBufferPool creates a new instance of HugeBufferBoundedPool with the specified capacity. The capacity must be between 1 and math.MaxUint32 and will be rounded up to the next power of two.
type HugeBufferPool ¶
type HugeBufferPool = IndirectPool[HugeBuffer]
HugeBufferPool represents a generic object pool that uses indirect indices to Put and Get items of type HugeBuffer.
type IPAddr ¶
IPAddr represents a network address of type IP. It is a type alias for the net.IPAddr type.
func IPAddrFromSCTPAddr ¶
IPAddrFromSCTPAddr returns a new IPAddr based on the given SCTPAddr.
func IPAddrFromTCPAddr ¶
IPAddrFromTCPAddr returns a new IPAddr based on the given TCPAddr.
func IPAddrFromUDPAddr ¶
IPAddrFromUDPAddr returns a new IPAddr based on the given UDPAddr. It sets the IP and Zone fields of the IPAddr with the values from the UDPAddr.
type IndirectPool ¶
type IndirectPool[T any] interface { Pool[int] // Value returns the value with the given indirect index Value(indirect int) T // SetValue sets the value with the given indirect index SetValue(indirect int, item T) }
IndirectPool is a generic object pool that Put and Get the int type indices of items instead of direct values. It extends the Pool[int] interface and adds Value and SetValue methods for working with indirect indices.
type Interface ¶
type Interface interface {
// AddListen adds listen event on the given listener with the given event handler
AddListen(listener Listener, handler AcceptedHandler)
// AddIO adds io event with the given event handlers
AddIO(dispatch DispatchHandler, message MessageHandler, written WrittenHandler, closed ClosedHandler)
// AddTimer adds timer event with the given event handler
AddTimer(ticked TickedHandler)
// Serve starts serving
Serve() error
// Poll waits for events. The d parameter specifies the duration that Poll will block
// d == 0 means Poll method will return immediately even if there is no events came
// d < 0 means Poll method will block forever or until there are any events
Poll(d time.Duration) error
}
Interface is the interface of sox events notification library
type InvalidAddrError ¶
type InvalidAddrError = net.InvalidAddrError
InvalidAddrError is an error type that represents an invalid network address.
type ItemConsumer ¶
type ItemConsumer[ItemType any] interface { // Consume consumes items Consume() (item ItemType, err error) }
ItemConsumer is the interface that Consume items
type ItemProducer ¶
type ItemProducer[ItemType any] interface { // Produce produces items Produce(item ItemType) error // Close closed the ItemProducer Close() error }
ItemProducer is the interface that Produce items and can be Close
type LargeBuffer ¶
type LargeBuffer [BufferSizeLarge]byte
LargeBuffer represents a byte array with size of BufferSizeLarge
func NewLargeBuffer ¶
func NewLargeBuffer() LargeBuffer
NewLargeBuffer returns a new instance of LargeBuffer.
func (LargeBuffer) Reset ¶
func (b LargeBuffer) Reset()
type LargeBufferBoundedPool ¶
type LargeBufferBoundedPool = BoundedPool[LargeBuffer]
LargeBufferBoundedPool is a type alias of BoundedPool[LargeBuffer].
func NewLargeBufferPool ¶
func NewLargeBufferPool(capacity int) *LargeBufferBoundedPool
NewLargeBufferPool creates a new instance of LargeBufferBoundedPool with the specified capacity. The capacity must be between 1 and math.MaxUint32 and will be rounded up to the next power of two.
type LargeBufferPool ¶
type LargeBufferPool = IndirectPool[LargeBuffer]
LargeBufferPool represents a generic object pool that uses indirect indices to Put and Get items of type LargeBuffer.
type Listener ¶
Listener represents a generic network listener. It is an alias for the net.Listener type.
type ListenerSocket ¶
type ListenerSocket interface {
Socket
// Accept accepts incoming connections and returns a new socket for the accepted connection.
Accept() (Socket, error)
}
ListenerSocket is an interface that represents a network socket capable of accepting incoming connections. It extends the Socket interface and adds the Accept method which returns a new socket for the accepted connection.
type MediumBuffer ¶
type MediumBuffer [BufferSizeMedium]byte
MediumBuffer represents a byte array with size of BufferSizeMedium
func NewMediumBuffer ¶
func NewMediumBuffer() MediumBuffer
NewMediumBuffer returns a new instance of MediumBuffer.
func (MediumBuffer) Reset ¶
func (b MediumBuffer) Reset()
type MediumBufferBoundedPool ¶
type MediumBufferBoundedPool = BoundedPool[MediumBuffer]
MediumBufferBoundedPool is a type alias of BoundedPool[MediumBuffer].
func NewMediumBufferPool ¶
func NewMediumBufferPool(capacity int) *MediumBufferBoundedPool
NewMediumBufferPool creates a new instance of MediumBufferBoundedPool with the specified capacity. The capacity must be between 1 and math.MaxUint32 and will be rounded up to the next power of two.
type MediumBufferPool ¶
type MediumBufferPool = IndirectPool[MediumBuffer]
MediumBufferPool represents a generic object pool that uses indirect indices to Put and Get items of type MediumBuffer.
type MessageHandler ¶
type MessageHandler interface {
ServeMessage(ctx context.Context, reply PollWriter, request PollReader)
}
MessageHandler is the most often used handle. It handles the incoming request messages
type MessageOptions ¶
type MessageOptions struct {
// ReadByteOrder sets which byte order will be used when reading data
ReadByteOrder binary.ByteOrder
// WriteByteOrder sets which byte order will be used when writing data
WriteByteOrder binary.ByteOrder
// ReadProto sets which protocol type will be used when reading data
ReadProto UnderlyingProtocol
// WriteProto sets which protocol type will be used when writing data
WriteProto UnderlyingProtocol
// ReadLimit is the maximum message payload data size
// A ReadLimit of zero indicates that there is no limit
ReadLimit int
// Nonblock if the nonblock flag is true, Message will not block on I/O
Nonblock bool
}
MessageOptions represents message feature options
type MicroBuffer ¶
type MicroBuffer [BufferSizeMicro]byte
MicroBuffer represents a byte array with size of BufferSizeMicro
func NewMicroBuffer ¶
func NewMicroBuffer() MicroBuffer
NewMicroBuffer returns a new instance of MicroBuffer.
func (MicroBuffer) Reset ¶
func (b MicroBuffer) Reset()
type MicroBufferBoundedPool ¶
type MicroBufferBoundedPool = BoundedPool[MicroBuffer]
MicroBufferBoundedPool is a type alias of BoundedPool[MicroBuffer].
func NewMicroBufferPool ¶
func NewMicroBufferPool(capacity int) *MicroBufferBoundedPool
NewMicroBufferPool creates a new instance of MicroBufferBoundedPool with the specified capacity. The capacity must be between 1 and math.MaxUint32 and will be rounded up to the next power of two.
type MicroBufferPool ¶
type MicroBufferPool = IndirectPool[MicroBuffer]
MicroBufferPool represents a generic object pool that uses indirect indices to Put and Get items of type MicroBuffer.
type NanoBuffer ¶
type NanoBuffer [BufferSizeNano]byte
NanoBuffer represents a byte array with size of BufferSizeNano
func NewNanoBuffer ¶
func NewNanoBuffer() NanoBuffer
NewNanoBuffer returns a new instance of NanoBuffer.
func (NanoBuffer) Reset ¶
func (b NanoBuffer) Reset()
type NanoBufferBoundedPool ¶
type NanoBufferBoundedPool = BoundedPool[NanoBuffer]
NanoBufferBoundedPool is a type alias of BoundedPool[NanoBuffer].
func NewNanoBufferPool ¶
func NewNanoBufferPool(capacity int) *NanoBufferBoundedPool
NewNanoBufferPool creates a new instance of NanoBufferBoundedPool with the specified capacity. The capacity must be between 1 and math.MaxUint32 and will be rounded up to the next power of two.
type NanoBufferPool ¶
type NanoBufferPool = IndirectPool[NanoBuffer]
NanoBufferPool represents a generic object pool that uses indirect indices to Put and Get items of type NanoBuffer. It implements the IndirectPool interface.
type NetworkType ¶
type NetworkType int
NetworkType is a custom type used to represent network types in the code.
const ( // NetworkUnix represents a constant value used to indicate the Unix network type. NetworkUnix NetworkType = 1 // NetworkIPv4 represents a constant value used to indicate the IPv4 network type. NetworkIPv4 NetworkType = 2 // NetworkIPv6 represents a constant value used to indicate the IPv6 network type. NetworkIPv6 NetworkType = 10 )
type OpError ¶
OpError is an error that represents an operation error along with the operation name, network protocol, source address, target address, and the underlying error. It is an alias for net.OpError.
type OpcodePacketReader ¶
type OpcodePacketReader interface {
PacketReader
// ReadOpcodeCommand reads an opcode command from the packet.
// It returns the opcode and cmd integers, and any error that occurred.
ReadOpcodeCommand() (opcode int, cmd int, err error)
}
OpcodePacketReader is an interface that extends the PacketReader interface, adding a method ReadOpcodeCommand, which reads an opcode command from the packet.
type OpcodePacketWriter ¶
type OpcodePacketWriter interface {
PacketWriter
// WriteOpcodeCommand writes an opcode command to the PacketWriter.
// The opcode specifies the type of command, and the cmd parameter
// provides additional information about the command.
// The returned error indicates any error that occurred during writing.
//
// Parameters:
// - opcode: The opcode of the command to be written.
// - cmd: Additional information about the command.
//
// Returns:
// - error: An error if any occurred during writing.
WriteOpcodeCommand(opcode int, cmd int) error
}
OpcodePacketWriter is an interface that extends the PacketWriter interface, adding a method for writing opcode commands.
type Options ¶
type Options struct {
// UserPoll sets if it's need to call Interface.Poll to wait events manually
// set UserPoll to true might improve performance of some IO operations
UserPoll bool
// Parallel sets the number of goroutines that do handle the events. Default value is 0
// Parallel <= 0 means the events will be handled at the same goroutine as the polling goroutine
// Parallel == 1 means the events will be handled in series at one another worker goroutine
// Parallel >= 2 means the events will be handled in parallel at Parallel worker goroutines
// It is possible to specify which worker will be used to handle the event
// by implement your customized DispatchHandler
Parallel int
}
Options represents
type PacketReader ¶
type PacketReader interface {
io.Reader
io.WriterTo
io.ByteReader
io.RuneReader
ReadBool() (bool, error)
ReadInt8() (int8, error)
ReadUint8() (uint8, error)
ReadInt16() (int16, error)
ReadUint16() (uint16, error)
ReadInt32() (int32, error)
ReadUint32() (uint32, error)
ReadInt64() (int64, error)
ReadUint64() (uint64, error)
ReadFloat32() (float32, error)
ReadFloat64() (float64, error)
ReadComplex64() (complex64, error)
ReadComplex128() (complex128, error)
ReadObject(object io.Writer) error
ReadBytes(delim byte) (line []byte, err error)
ReadString(delim byte) (line string, err error)
ReadFixedBytes(n int) ([]byte, error)
ReadFixedString(n int) (string, error)
Writer() PacketWriter
}
PacketReader is the interface that wraps common used methods that reads numerics, byte slices, strings etc.
func NewPacketReader ¶
func NewPacketReader(buffer *bytes.Buffer, order binary.ByteOrder) PacketReader
NewPacketReader creates and returns a new PacketReader with the given buffer and byte order
type PacketWriter ¶
type PacketWriter interface {
io.Writer
io.ReaderFrom
io.ByteWriter
WriteRune(r rune) (n int, err error)
WriteBool(val bool) PacketWriter
WriteInt8(val int8) PacketWriter
WriteUint8(val uint8) PacketWriter
WriteInt16(val int16) PacketWriter
WriteUint16(val uint16) PacketWriter
WriteInt32(val int32) PacketWriter
WriteUint32(val uint32) PacketWriter
WriteInt64(val int64) PacketWriter
WriteUint64(val uint64) PacketWriter
WriteFloat32(val float32) PacketWriter
WriteFloat64(val float64) PacketWriter
WriteComplex64(val complex64) PacketWriter
WriteComplex128(val complex128) PacketWriter
WriteObject(object io.Reader) error
WriteString(s string) (n int, err error)
Reset()
Reader() PacketReader
}
PacketWriter is the interface that wraps common used methods that writes or puts numerics, byte slices, strings etc.
func NewPacketWriter ¶
func NewPacketWriter(buffer *bytes.Buffer, order binary.ByteOrder) PacketWriter
NewPacketWriter creates and returns a new PacketWriter with the given buffer and byte order
type ParamSpinWait ¶
type ParamSpinWait struct {
Level int8
// contains filtered or unexported fields
}
ParamSpinWait is a type that represents a parameterized version of SpinWait. It is used for lightweight synchronization in low-level scenarios with lower cost. The zero value of ParamSpinWait is already initialized and ready to use.
func NewParamSpinWait ¶
func NewParamSpinWait() ParamSpinWait
NewParamSpinWait returns a new instance of ParamSpinWait with default values.
func NewSpinWaitWithLevel ¶
func NewSpinWaitWithLevel(level int8) ParamSpinWait
NewSpinWaitWithLevel returns a new instance of ParamSpinWait with the specified level. The level determines the preemptive behavior of the spin wait, where higher levels result in less delay but more CPU consumption.
func (*ParamSpinWait) Closed ¶
func (sw *ParamSpinWait) Closed() bool
Closed returns true if the limit is greater than 0 and the current count is equal or greater than the limit.
func (*ParamSpinWait) Once ¶
func (sw *ParamSpinWait) Once()
Once performs a single spin operation based on the provided preemptive level.
func (*ParamSpinWait) OnceWithLevel ¶
func (sw *ParamSpinWait) OnceWithLevel(level int)
OnceWithLevel performs a single spin with the given preemptive level.
func (*ParamSpinWait) Reset ¶
func (sw *ParamSpinWait) Reset()
Reset resets the internal counters of the ParamSpinWait instance to their initial values.
func (*ParamSpinWait) SetLevel ¶
func (sw *ParamSpinWait) SetLevel(level int) *ParamSpinWait
SetLevel sets the preemptive Level of the ParamSpinWait to the specified value. Higher preemptive level result in less delay, but more CPU consumption.
func (*ParamSpinWait) SetLimit ¶
func (sw *ParamSpinWait) SetLimit(limit int) *ParamSpinWait
SetLimit sets the limit for the number of times the spin waite can spin before yielding.
func (*ParamSpinWait) WillYield ¶
func (sw *ParamSpinWait) WillYield() bool
WillYield returns true if the spin wait should yield the processor,
func (*ParamSpinWait) WillYieldWithLevel ¶
func (sw *ParamSpinWait) WillYieldWithLevel(level int8) bool
WillYieldWithLevel returns true if the spin wait should yield the processor based on the provided preemptive level.
type PicoBuffer ¶
type PicoBuffer [BufferSizePico]byte
PicoBuffer represents a byte array with size of BufferSizePico
func (PicoBuffer) Reset ¶
func (b PicoBuffer) Reset()
type PicoBufferBoundedPool ¶
type PicoBufferBoundedPool = BoundedPool[PicoBuffer]
PicoBufferBoundedPool is a type alias of BoundedPool[PicoBuffer].
func NewPicoBufferPool ¶
func NewPicoBufferPool(capacity int) *PicoBufferBoundedPool
NewPicoBufferPool creates a new instance of PicoBufferBoundedPool with the specified capacity. The capacity must be between 1 and math.MaxUint32 and will be rounded up to the next power of two.
type PicoBufferPool ¶
type PicoBufferPool = IndirectPool[PicoBuffer]
PicoBufferPool represents a generic object pool that uses indirect indices to Put and Get items of type PicoBuffer.
type PollCloser ¶
PollCloser is the interface that groups Fd and the basic Close method
type PollFd ¶
type PollFd interface {
// Fd returns the file descriptor
Fd() int
}
PollFd is the interface that warps Fd
type PollReadCloser ¶
type PollReadCloser interface {
PollReader
io.Closer
}
PollReadCloser is the interface that groups the methods in interface PollReader and PollCloser
type PollReadWriteCloser ¶
type PollReadWriteCloser interface {
PollReader
PollWriter
io.Closer
}
PollReadWriteCloser is the interface that groups the methods in interface PollReader, PollWriter and PollCloser
type PollReadWriter ¶
type PollReadWriter interface {
PollReader
PollWriter
}
PollReadWriter is the interface that groups the methods in interface PollReader and PollWriter
type PollReader ¶
PollReader is the interface that groups Fd and the basic Read method
type PollSignalfd ¶
type PollSignalfd interface {
PollFd
// ReadSiginfo reads and returns the came signal info
ReadSiginfo() (sig unix.Signal, code int, err error)
}
PollSignalfd is the interface that groups Fd and ReadSiginfo method
func NewSignalFile ¶
func NewSignalFile() (signalFile PollSignalfd, err error)
NewSignalFile creates and returns a new signal fd
type PollUintReadCloser ¶
type PollUintReadCloser interface {
PollUintReader
io.Closer
}
PollUintReadCloser is the interface that groups the methods in interface PollUintReader and PollUintCloser
type PollUintReadWriteCloser ¶
type PollUintReadWriteCloser interface {
PollUintReader
PollUintWriter
io.Closer
}
PollUintReadWriteCloser is the interface that groups the methods in interface PollUintReader, PollUintWriter and PollCloser
func NewEventfd ¶
func NewEventfd() (PollUintReadWriteCloser, error)
NewEventfd creates and returns a new nonblocking eventfd as a PollUintReadWriteCloser
type PollUintReadWriter ¶
type PollUintReadWriter interface {
PollUintReader
PollUintWriter
}
PollUintReadWriter is the interface that groups the methods in interface PollUintReader and PollUintWriter
type PollUintReader ¶
type PollUintReader interface {
PollReader
ReadUint() (val uint, err error)
}
PollUintReader is the interface that groups ReadUint() and the methods in interface PollReader
type PollUintWriteCloser ¶
type PollUintWriteCloser interface {
PollUintWriter
io.Closer
}
PollUintWriteCloser is the interface that groups the methods in interface PollUintWriter and PollCloser
type PollUintWriter ¶
type PollUintWriter interface {
PollWriter
WriteUint(val uint) error
}
PollUintWriter is the interface that groups WriteUint() and the methods in interface PollWriter
type PollWriteCloser ¶
type PollWriteCloser interface {
PollWriter
io.Closer
}
PollWriteCloser is the interface that groups the methods in interface PollWriter and PollCloser
type PollWriter ¶
PollWriter is the interface that groups Fd and the basic Write method
type Pool ¶
type Pool[T any] interface { // Put adds item to the pool // If the Pool is a nonblocking bounded pool, ErrTemporarilyUnavailable // will be returned when the Pool is full. // If the Pool is a bounded pool but not nonblocking, // Put would block until the Pool is no longer full // Note that if the Pool is not nonblocking, the return error can be ignored Put(item T) error // Get selects an arbitrary item from the Pool, // removes it from the Pool, and returns it to the caller. // If the Pool is empty and has been set to nonblocking, // ErrTemporarilyUnavailable will be returned. // If the Pool is empty and has been not set to nonblocking, // Get would block until any item put back to the Pool // Note that if the Pool is not nonblocking, the return error can be ignored Get() (item T, err error) }
Pool is a generic object pool
type RawConn ¶
type RawConn struct {
*RawSocket
// contains filtered or unexported fields
}
func (RawConn) NetworkType ¶
func (so RawConn) NetworkType() NetworkType
func (*RawConn) RemoteAddr ¶
type RawSocket ¶
type RawSocket struct {
// contains filtered or unexported fields
}
func (RawSocket) NetworkType ¶
func (so RawSocket) NetworkType() NetworkType
func (*RawSocket) Protocol ¶
func (so *RawSocket) Protocol() UnderlyingProtocol
type RegisterBuffer ¶
type RegisterBuffer [registerBufferSize]byte
RegisterBuffer represents a fixed-size buffer used for registering with the I/O ring.
type RegisterBufferPool ¶
type RegisterBufferPool = BoundedPool[RegisterBuffer]
RegisterBufferPool represents a pool of fixed-size buffers used for registering with the I/O ring.
func NewRegisterBufferPool ¶
func NewRegisterBufferPool(capacity int) *RegisterBufferPool
NewRegisterBufferPool creates a new instance of RegisterBufferPool with the specified capacity.
type RingQueueOptions ¶
type RingQueueOptions struct {
// Capacity specifies the capacity of queue. The default Capacity is 32K
Capacity int
// ConcurrentProduce specifies whether the ItemProducer works concurrently or not
// It should be set as true, if there are multiple goroutines doing Produce operations
ConcurrentProduce bool
// ConcurrentConsume specifies whether the ItemConsumer works concurrently or not
// It should be set as true, if there are multiple goroutines doing Consumer operations
ConcurrentConsume bool
// Nonblocking specifies whether the Produce or Consume operations will NOT block
// even if it is temporarily unavailable or not
Nonblocking bool
}
RingQueueOptions holds optional parameters for RingQueue implementations
type SCTPAddr ¶
SCTPAddr represents the address of a SCTP endpoint. It contains the IP address, port number, and IPv6 zone.
func ResolveSCTPAddr ¶
ResolveSCTPAddr resolves the SCTP network address of the given network and address string. It returns a new SCTPAddr based on the resolved address and network. Possible network values are "sctp", "sctp4", and "sctp6".
func SCTPAddrFromAddrPort ¶
SCTPAddrFromAddrPort returns a new SCTPAddr based on the given netip.AddrPort.
type SCTPConn ¶
type SCTPConn struct {
*SCTPSocket
// contains filtered or unexported fields
}
func (SCTPConn) NetworkType ¶
func (so SCTPConn) NetworkType() NetworkType
func (*SCTPConn) RemoteAddr ¶
type SCTPListener ¶
type SCTPListener struct {
*SCTPSocket
// contains filtered or unexported fields
}
func ListenSCTP4 ¶
func ListenSCTP4(laddr *SCTPAddr) (*SCTPListener, error)
func ListenSCTP6 ¶
func ListenSCTP6(laddr *SCTPAddr) (*SCTPListener, error)
func (*SCTPListener) Accept ¶
func (l *SCTPListener) Accept() (Conn, error)
func (*SCTPListener) Addr ¶
func (l *SCTPListener) Addr() Addr
func (*SCTPListener) Close ¶
func (l *SCTPListener) Close() error
func (SCTPListener) NetworkType ¶
func (so SCTPListener) NetworkType() NetworkType
type SCTPSocket ¶
type SCTPSocket struct {
// contains filtered or unexported fields
}
func (*SCTPSocket) Bind ¶
func (so *SCTPSocket) Bind(addr ...*SCTPAddr) error
Bind binds addresses to the SCTP socket
func (SCTPSocket) NetworkType ¶
func (so SCTPSocket) NetworkType() NetworkType
func (*SCTPSocket) Protocol ¶
func (so *SCTPSocket) Protocol() UnderlyingProtocol
func (*SCTPSocket) Shutdown ¶
func (so *SCTPSocket) Shutdown(how int) error
type SmallBuffer ¶
type SmallBuffer [BufferSizeSmall]byte
SmallBuffer represents a byte array with size of BufferSizeSmall
func NewSmallBuffer ¶
func NewSmallBuffer() SmallBuffer
NewSmallBuffer returns a new instance of SmallBuffer.
func (SmallBuffer) Reset ¶
func (b SmallBuffer) Reset()
type SmallBufferBoundedPool ¶
type SmallBufferBoundedPool = BoundedPool[SmallBuffer]
SmallBufferBoundedPool is a type alias of BoundedPool[SmallBuffer].
func NewSmallBufferPool ¶
func NewSmallBufferPool(capacity int) *SmallBufferBoundedPool
NewSmallBufferPool creates a new instance of SmallBufferBoundedPool with the specified capacity. The capacity must be between 1 and math.MaxUint32 and will be rounded up to the next power of two.
type SmallBufferPool ¶
type SmallBufferPool = IndirectPool[SmallBuffer]
SmallBufferPool represents a generic object pool that uses indirect indices to Put and Get items of type SmallBuffer.
type Sockaddr ¶
Sockaddr is an alias for the unix.Sockaddr type.
func AddrToSockaddr ¶
AddrToSockaddr takes a network address and returns the Sockaddr type socket address.
func NetworkAddressToSockaddr ¶
NetworkAddressToSockaddr returns the corresponding Sockaddr type socket address. It resolves the network address and creates a Sockaddr based on the network type.
type SockaddrInet4 ¶
type SockaddrInet4 = unix.SockaddrInet4
SockaddrInet4 is an alias for the unix.SockaddrInet4 type.
type SockaddrInet6 ¶
type SockaddrInet6 = unix.SockaddrInet6
SockaddrInet6 is an alias for the unix.SockaddrInet6 type.
type SockaddrUnix ¶
type SockaddrUnix = unix.SockaddrUnix
SockaddrUnix is an alias for the unix.SockaddrUnix type.
type Socket ¶
type Socket interface {
// Fd returns the file descriptor associated with the socket.
Fd() int
// NetworkType returns the network type associated with the socket.
NetworkType() NetworkType
// Protocol returns the underlying protocol of the Socket.
// It indicates the transmission protocol features.
Protocol() UnderlyingProtocol
// Reader is an interface that represents an object that can read data.
io.Reader
// Writer is an interface that represents a data writer.
io.Writer
// Closer is an interface implemented by objects that can be closed.
io.Closer
}
Socket is a generic network socket
func SocketPair ¶
type SpinWait ¶
type SpinWait struct {
// contains filtered or unexported fields
}
SpinWait is a lightweight synchronization type that you can use in low-level scenarios with lower cost. The zero value for SpinWait is ready to use.
type Spinlock ¶
type Spinlock struct {
// contains filtered or unexported fields
}
Spinlock is a synchronization type that provides a simple spinlock mechanism. The zero value for Spinlock is ready to use.
func (*Spinlock) Lock ¶
func (sl *Spinlock) Lock()
Lock attempts to acquire the spinlock. If it fails, it will spin wait until it succeeds.
func (*Spinlock) SpinOnce ¶
func (sl *Spinlock) SpinOnce()
SpinOnce performs a single spin using the SpinWait synchronization type.
type Stack ¶
type Stack[ItemType any] interface { // Push inserts an element at the of the Stack // It returns io.ErrClosesPipe if the Stack is closed. // If the Stack is full and the Nonblocking option is set as true, // an ErrTemporarilyUnavailable will be returned. // If the Stack is full and the Nonblocking option is set as false, // the Push operation blocks until the Stack became not full Push(item ItemType) error // Pop removes and returns the element at the top of the Stack // When the Stack is empty, // It returns the zero-value and io.EOF if the Stack is already closed. // It returns the zero-value and ErrTemporarilyUnavailable if the Stack is set as Nonblocking. // If the stack is not set as Nonblocking, it blocks until any element has been Pushed. Pop() (item ItemType, err error) // Close closes the Stack. The return value is always nil. Close() error }
Stack is the interface that wraps Push and Pop operations on a Stack
func NewFixedStack ¶
func NewFixedStack[ItemType any](opts ...func(options *FixedStackOptions)) (Stack[ItemType], error)
NewFixedStack creates and returns a fixed capacity Stack with the given options
type TCPAddr ¶
TCPAddr represents the address of a TCP endpoint. It is a type alias for the net.TCPAddr type.
type TCPConn ¶
type TCPConn struct {
*TCPSocket
// contains filtered or unexported fields
}
func (TCPConn) NetworkType ¶
func (so TCPConn) NetworkType() NetworkType
func (*TCPConn) RemoteAddr ¶
type TCPListener ¶
type TCPListener struct {
*TCPSocket
// contains filtered or unexported fields
}
func ListenTCP4 ¶
func ListenTCP4(laddr *TCPAddr) (*TCPListener, error)
func ListenTCP6 ¶
func ListenTCP6(laddr *TCPAddr) (*TCPListener, error)
func (*TCPListener) Accept ¶
func (l *TCPListener) Accept() (Conn, error)
func (*TCPListener) Addr ¶
func (l *TCPListener) Addr() Addr
func (TCPListener) NetworkType ¶
func (so TCPListener) NetworkType() NetworkType
type TCPSocket ¶
type TCPSocket struct {
// contains filtered or unexported fields
}
func (TCPSocket) NetworkType ¶
func (so TCPSocket) NetworkType() NetworkType
func (*TCPSocket) Protocol ¶
func (so *TCPSocket) Protocol() UnderlyingProtocol
type TickedHandler ¶
TickedHandler handles timer events
type Timer ¶
type Timer interface {
Now() time.Time
PollReadCloser
}
type UDPAddr ¶
UDPAddr represents the address of a UDP endpoint. It is a type alias for the net.UDPAddr type.
type UDPConn ¶
type UDPConn struct {
*UDPSocket
// contains filtered or unexported fields
}
func ListenUDP4 ¶
func ListenUDP6 ¶
func (UDPConn) NetworkType ¶
func (so UDPConn) NetworkType() NetworkType
func (*UDPConn) RemoteAddr ¶
type UDPSocket ¶
type UDPSocket struct {
// contains filtered or unexported fields
}
func (UDPSocket) NetworkType ¶
func (so UDPSocket) NetworkType() NetworkType
func (*UDPSocket) Protocol ¶
func (so *UDPSocket) Protocol() UnderlyingProtocol
type UnderlyingProtocol ¶
type UnderlyingProtocol int
UnderlyingProtocol represents transmission protocol features
const ( // UnderlyingProtocolStream means the underlying protocol works like a stream UnderlyingProtocolStream UnderlyingProtocol = 1 // UnderlyingProtocolDgram means the underlying protocol works like datagram UnderlyingProtocolDgram UnderlyingProtocol = 2 // UnderlyingProtocolRaw means the underlying protocol works rawly UnderlyingProtocolRaw UnderlyingProtocol = 3 // UnderlyingProtocolSeqPacket means the underlying protocol works like a sequenced packet UnderlyingProtocolSeqPacket UnderlyingProtocol = 5 )
func (UnderlyingProtocol) PreserveBoundary ¶
func (t UnderlyingProtocol) PreserveBoundary() bool
PreserveBoundary returns true if the underlying protocol preserves message boundaries
type UnixAddr ¶
UnixAddr represents a Unix domain socket address. It is an alias for the net.UnixAddr type.
type UnixConn ¶
type UnixConn struct {
*UnixSocket
// contains filtered or unexported fields
}
func (UnixConn) NetworkType ¶
func (so UnixConn) NetworkType() NetworkType
func (*UnixConn) RemoteAddr ¶
type UnixListener ¶
type UnixListener struct {
*UnixSocket
// contains filtered or unexported fields
}
func ListenUnix ¶
func ListenUnix(laddr *UnixAddr) (*UnixListener, error)
func (*UnixListener) Accept ¶
func (l *UnixListener) Accept() (Conn, error)
func (*UnixListener) Addr ¶
func (l *UnixListener) Addr() Addr
func (*UnixListener) Close ¶
func (l *UnixListener) Close() error
func (UnixListener) NetworkType ¶
func (so UnixListener) NetworkType() NetworkType
type UnixSocket ¶
type UnixSocket struct {
// contains filtered or unexported fields
}
func (UnixSocket) NetworkType ¶
func (so UnixSocket) NetworkType() NetworkType
func (*UnixSocket) Protocol ¶
func (so *UnixSocket) Protocol() UnderlyingProtocol
func (*UnixSocket) Shutdown ¶
func (so *UnixSocket) Shutdown(how int) error
type UnknownNetworkError ¶
type UnknownNetworkError = net.UnknownNetworkError
UnknownNetworkError represents an error when an unknown network is encountered. The error is typically returned when unexpected network types are encountered in network-related operations.
type Uring ¶
type Uring struct {
*UringOptions
Features *UringFeatures
// contains filtered or unexported fields
}
func NewUring ¶
func NewUring(options ...func(options *UringOptions)) (*Uring, error)
func (*Uring) AsyncCancel ¶
func (ur *Uring) AsyncCancel(ctx context.Context, userdata *ioUringCtx, options ...UringOpOptionFunc) error
AsyncCancel cancels pending async operation
func (*Uring) Close ¶
func (ur *Uring) Close(ctx context.Context, file PollCloser, options ...UringOpOptionFunc) error
Close closes file descriptor
func (*Uring) Connect ¶
func (ur *Uring) Connect(ctx context.Context, so Socket, remote Addr, options ...UringOpOptionFunc) error
Connect initiates socket connection to remote address
func (*Uring) Fallocate ¶
func (ur *Uring) Fallocate(ctx context.Context, fd int, mode uint32, offset int64, length int64, options ...UringOpOptionFunc) error
Fallocate allocates space for file
func (*Uring) FileAdvise ¶
func (ur *Uring) FileAdvise(ctx context.Context, fd int, offset int64, length int, advice int, options ...UringOpOptionFunc) error
FileAdvise provides advice about file access patterns
func (*Uring) LinkTimeout ¶
func (ur *Uring) LinkTimeout(ctx context.Context, d time.Duration, options ...UringOpOptionFunc) error
LinkTimeout creates linked timeout operation
func (*Uring) Listen ¶
Listen starts listening on a given socket with the specified options and manages I/O operations using io_uring. Listen starts socket listening with given options
func (*Uring) Nop ¶
func (ur *Uring) Nop(ctx context.Context, options ...UringOpOptionFunc) error
Nop submits no-op request
func (*Uring) OpenAt ¶
func (ur *Uring) OpenAt(ctx context.Context, dirfd int, pathname string, flags int, mode uint32, options ...UringOpOptionFunc) error
OpenAt opens file at given path relative to directory fd
func (*Uring) PollAdd ¶
func (ur *Uring) PollAdd(ctx context.Context, fd int, events int, options ...UringOpOptionFunc) error
PollAdd adds file descriptor to poll set
func (*Uring) PollRemove ¶
func (ur *Uring) PollRemove(ctx context.Context, options ...UringOpOptionFunc) error
PollRemove removes file descriptor from poll set
func (*Uring) ReadFixed ¶
func (ur *Uring) ReadFixed(ctx context.Context, fd int, bufIndex int, options ...UringOpOptionFunc) ([]byte, error)
ReadFixed performs read with fixed buffer
func (*Uring) ReadV ¶
func (ur *Uring) ReadV(ctx context.Context, fd int, iovs [][]byte, options ...UringOpOptionFunc) error
ReadV performs vectored read operation
func (*Uring) Receive ¶
func (ur *Uring) Receive(ctx context.Context, so Socket, b []byte, options ...UringOpOptionFunc) error
Receive performs socket receive operation
func (*Uring) RecvMsg ¶
func (ur *Uring) RecvMsg(ctx context.Context, so PollFd, buffers [][]byte, oob []byte, options ...UringOpOptionFunc) error
RecvMsg receives message with control data
func (*Uring) SCTP4Socket ¶
func (ur *Uring) SCTP4Socket(ctx context.Context, options ...UringOpOptionFunc) error
func (*Uring) SCTP6Socket ¶
func (ur *Uring) SCTP6Socket(ctx context.Context, options ...UringOpOptionFunc) error
func (*Uring) SendMsg ¶
func (ur *Uring) SendMsg(ctx context.Context, so PollFd, buffers [][]byte, oob []byte, to Addr, options ...UringOpOptionFunc) error
SendMsg sends message with control data
func (*Uring) Shutdown ¶
func (ur *Uring) Shutdown(ctx context.Context, so Socket, how int, options ...UringOpOptionFunc) error
Shutdown gracefully closes socket
func (*Uring) Splice ¶
func (ur *Uring) Splice(ctx context.Context, fdIn, fdOut int, len int, options ...UringOpOptionFunc) error
Splice transfers data between file descriptors
func (*Uring) SyncFileRange ¶
func (ur *Uring) SyncFileRange(ctx context.Context, fd int, offset int64, length int, flags int, options ...UringOpOptionFunc) error
SyncFileRange syncs file range to storage
func (*Uring) TCP4Socket ¶
func (ur *Uring) TCP4Socket(ctx context.Context, options ...UringOpOptionFunc) error
func (*Uring) TCP6Socket ¶
func (ur *Uring) TCP6Socket(ctx context.Context, options ...UringOpOptionFunc) error
func (*Uring) Tee ¶
func (ur *Uring) Tee(ctx context.Context, fdIn, fdOut int, length int, options ...UringOpOptionFunc) error
Tee duplicates data between pipes
func (*Uring) TimeoutRemove ¶
func (ur *Uring) TimeoutRemove(ctx context.Context, userData unsafe.Pointer, options ...UringOpOptionFunc) error
TimeoutRemove removes timeout request
func (*Uring) UDP4Socket ¶
func (ur *Uring) UDP4Socket(ctx context.Context, options ...UringOpOptionFunc) error
func (*Uring) UDP6Socket ¶
func (ur *Uring) UDP6Socket(ctx context.Context, options ...UringOpOptionFunc) error
func (*Uring) UDPLITE4Socket ¶
func (ur *Uring) UDPLITE4Socket(ctx context.Context, options ...UringOpOptionFunc) error
func (*Uring) UDPLITE6Socket ¶
func (ur *Uring) UDPLITE6Socket(ctx context.Context, options ...UringOpOptionFunc) error
func (*Uring) UnixSocket ¶
func (ur *Uring) UnixSocket(ctx context.Context, options ...UringOpOptionFunc) error
func (*Uring) Write ¶
func (ur *Uring) Write(ctx context.Context, fd int, b []byte, n int, options ...UringOpOptionFunc) error
Write performs write operation
func (*Uring) WriteFixed ¶
func (ur *Uring) WriteFixed(ctx context.Context, fd int, bufIndex int, n int, options ...UringOpOptionFunc) error
WriteFixed performs write with fixed buffer
type UringEvent ¶
type UringEvent struct {
*UringEventData
Result int32
Flags uint32
}
type UringEventData ¶
type UringFeatures ¶
type UringOpOption ¶
type UringOpOption struct {
Flags uint8
Callback uint8
Ioprio uint16
FileIndex uint32
Backlog int
ReadBufferSize int
WriteBufferSize int
Duration time.Duration
FileMode os.FileMode
Advice int
Offset int64
N *int
Count int
}
func (*UringOpOption) Apply ¶
func (uo *UringOpOption) Apply(opts ...UringOpOptionFunc)
type UringOpOptionFunc ¶
type UringOpOptionFunc func(opt *UringOpOption)
type UringOptionFunc ¶
type UringOptionFunc func(opt *UringOptions)
var ( UringLargeLockedBufferMemOptions UringOptionFunc = func(opt *UringOptions) { opt.LockedBufferMem = registerBufferSize * registerBufferNum } UringMultiSizeBufferOptions UringOptionFunc = func(opt *UringOptions) { opt.MultiSizeBuffer = 1 } )
type UringOptions ¶
type UringOptions struct {
Entries int
LockedBufferMem int
ReadBufferSize int
ReadBufferNum int
ReadBufferGidOffset int
WriteBufferSize int
WriteBufferNum int
MultiSizeBuffer int
MultiIssuers bool
NotifySucceed bool
IndirectSubmissionQueue bool
}
func (*UringOptions) Apply ¶
func (uo *UringOptions) Apply(opts ...UringOptionFunc)
type WrittenHandler ¶
type WrittenHandler interface {
ServeWritten(ctx context.Context, writer PollWriter)
}
WrittenHandler handles send message completed events
Source Files
¶
- bits_lp64.go
- bounded_pool.go
- buffers.go
- context.go
- epoll_linux.go
- eventfd_linux.go
- fixed_stack.go
- inet.go
- inet_unix.go
- interface.go
- message.go
- network.go
- network_unix.go
- opcode_packet.go
- packet.go
- poller.go
- poller_unix.go
- pool.go
- rawsock_linux.go
- ring_queue.go
- sctpsock_linux.go
- signal_linux.go
- sock.go
- sock_unix.go
- spin_wait.go
- spinlock.go
- sync_amd64.go
- sys_unix.go
- tcp_sock_linux.go
- timer.go
- timerfd_linux.go
- udp_sock_linux.go
- unet_unix.go
- unix_sock_linux.go
- uring_linux.go
- uring_linux_buffer_rings.go
- uring_linux_buffers.go
- uring_linux_event_lp64.go
- uring_linux_interface.go
- uring_linux_interface_internal.go
- uring_linux_op_option.go
- uring_linux_ops.go
- utils.go
- utils_unix.go