network

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 25, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TCPClient

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

func NewTCPClient

func NewTCPClient(addr string, opts ...TCPClientOption) (*TCPClient, error)

func (*TCPClient) Close

func (c *TCPClient) Close() error

func (*TCPClient) Send

func (c *TCPClient) Send(req []byte) ([]byte, error)

type TCPClientConfig

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

type TCPClientOption

type TCPClientOption func(o *TCPClientConfig)

func WithClientDialTimeout

func WithClientDialTimeout(d time.Duration) TCPClientOption

func WithClientReadBufferSize

func WithClientReadBufferSize(n int) TCPClientOption

func WithClientReadTimeout

func WithClientReadTimeout(d time.Duration) TCPClientOption

func WithClientWriteTimeout

func WithClientWriteTimeout(d time.Duration) TCPClientOption

type TCPHandler

type TCPHandler interface {
	Handle(ctx context.Context, req []byte) []byte
}

type TCPHandlerFunc

type TCPHandlerFunc func(ctx context.Context, req []byte) []byte

func (TCPHandlerFunc) Handle

func (fn TCPHandlerFunc) Handle(ctx context.Context, req []byte) []byte

type TCPServer

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

func NewTCPServer

func NewTCPServer(logger *slog.Logger, opts ...TCPServerOption) (*TCPServer, error)

func (*TCPServer) ListenAddr added in v1.2.0

func (s *TCPServer) ListenAddr() string

func (*TCPServer) ListenPort

func (s *TCPServer) ListenPort() int

func (*TCPServer) ServeHandler

func (s *TCPServer) ServeHandler(h TCPHandler)

func (*TCPServer) Shutdown

func (s *TCPServer) Shutdown(ctx context.Context) error

type TCPServerConfig

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

type TCPServerOption

type TCPServerOption func(c *TCPServerConfig)

func WithServerIdleTimeout

func WithServerIdleTimeout(d time.Duration) TCPServerOption

func WithServerListen

func WithServerListen(addr string) TCPServerOption

func WithServerMaxConnections

func WithServerMaxConnections(n int) TCPServerOption

func WithServerMaxMessageSize

func WithServerMaxMessageSize(n int) TCPServerOption

func WithServerWriteTimeout

func WithServerWriteTimeout(d time.Duration) TCPServerOption

Jump to

Keyboard shortcuts

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