Documentation
¶
Overview ¶
This package handles streaming listener protocols as an interface
Index ¶
- func NewClientConfig(opts ...ClientOptFunc) *client.ClientConfig
- type Client
- type ClientOptFunc
- func WithClientBufferSize(size int) ClientOptFunc
- func WithClientTimeouts(read, write time.Duration) ClientOptFunc
- func WithDelimiter(delimiter []byte) ClientOptFunc
- func WithQUICInsecureSkipVerify(skip bool) ClientOptFunc
- func WithQUICMinVersion(version uint16) ClientOptFunc
- func WithQUICNextProtos(protos []string) ClientOptFunc
- type Listener
- func NewTCPListener(host string, port uint16, opts ...ServerOptFunc) (Listener, error)
- func NewTCPListenerWithContext(host string, port uint16, ctx context.Context, opts ...ServerOptFunc) (Listener, error)
- func NewUDPListener(host string, port uint16, opts ...ServerOptFunc) (Listener, error)
- func NewUDPListenerWithContext(host string, port uint16, ctx context.Context, opts ...ServerOptFunc) (Listener, error)
- func NewWebSocketListener(host string, port uint16, opts ...ServerOptFunc) (Listener, error)
- func NewWebSocketListenerWithContext(host string, port uint16, ctx context.Context, opts ...ServerOptFunc) (Listener, error)
- type ServerOptFunc
- func WithBufferSize(size int) ServerOptFunc
- func WithLogger(logger listener.Logger) ServerOptFunc
- func WithMaxConnections(max int) ServerOptFunc
- func WithMaxLength(length uint32) ServerOptFunc
- func WithTimeouts(read, write time.Duration) ServerOptFunc
- func WithWebSocketBufferSizes(readSize, writeSize int) ServerOptFunc
- func WithWebSocketPath(path string) ServerOptFunc
- type WebSocketConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewClientConfig ¶ added in v0.0.9
func NewClientConfig(opts ...ClientOptFunc) *client.ClientConfig
Helper function to create a new client config with options
Types ¶
type Client ¶
type Client interface {
// Connect establishes a connection to the server
Connect(ctx context.Context) error
// Send sends data to the server
Send(data []byte) error
// Receive receives data from the server
Receive() ([]byte, error)
// Close closes the client connection
Close() error
// LocalAddr returns the local network address
LocalAddr() net.Addr
// RemoteAddr returns the remote network address
RemoteAddr() net.Addr
}
Client defines the interface for all client implementations
func NewQUICClient ¶ added in v0.0.9
func NewQUICClient(addr string, opts ...ClientOptFunc) (Client, error)
NewQUICClient creates a new QUIC client with the given address and options
func NewUDPClient ¶ added in v0.0.9
func NewUDPClient(addr string, opts ...ClientOptFunc) (Client, error)
NewUDPClient creates a new UDP client with the given address and options
type ClientOptFunc ¶ added in v0.0.9
type ClientOptFunc func(config *client.ClientConfig)
Common client options that apply to all protocols
func WithClientBufferSize ¶ added in v0.0.9
func WithClientBufferSize(size int) ClientOptFunc
WithClientBufferSize sets the read buffer size for any protocol
func WithClientTimeouts ¶ added in v0.0.9
func WithClientTimeouts(read, write time.Duration) ClientOptFunc
WithClientTimeouts sets read and write timeouts for any protocol
func WithDelimiter ¶ added in v0.0.9
func WithDelimiter(delimiter []byte) ClientOptFunc
WithDelimiter sets the message delimiter
func WithQUICInsecureSkipVerify ¶ added in v0.0.9
func WithQUICInsecureSkipVerify(skip bool) ClientOptFunc
QUIC specific options
func WithQUICMinVersion ¶ added in v0.0.9
func WithQUICMinVersion(version uint16) ClientOptFunc
func WithQUICNextProtos ¶ added in v0.0.9
func WithQUICNextProtos(protos []string) ClientOptFunc
type Listener ¶
type Listener interface {
// StartReceiveStream Starts listener for stream transport
StartListener() error
// StopReceiveStream Stops listener for stream transport
StopListener() error
// SetAnnounceNewSession Sets middleware for announcing a new session
SetAnnounceNewSession(function listener.AnnounceMiddlewareFunc, options any)
// GetActiveSessions Get all sessions
GetActiveSessions() map[string]listener.Session
// GetSession Get session from ClientAddr (IP:Port)
GetSession(ClientAddr string) listener.Session
}
Listener defines the interface for streaming TCP and UDP connections
func NewTCPListener ¶
func NewTCPListener(host string, port uint16, opts ...ServerOptFunc) (Listener, error)
NewTCPListener creates a new TCP stream handler
func NewTCPListenerWithContext ¶
func NewTCPListenerWithContext(host string, port uint16, ctx context.Context, opts ...ServerOptFunc) (Listener, error)
NewTCPListenerWithContext creates a new TCP stream handler with context
func NewUDPListener ¶
func NewUDPListener(host string, port uint16, opts ...ServerOptFunc) (Listener, error)
NewUDPListener creates a new UDP stream handler
func NewUDPListenerWithContext ¶
func NewUDPListenerWithContext(host string, port uint16, ctx context.Context, opts ...ServerOptFunc) (Listener, error)
NewUDPListenerWithContext creates a new UDP stream handler with context
func NewWebSocketListener ¶
func NewWebSocketListener(host string, port uint16, opts ...ServerOptFunc) (Listener, error)
NewWebSocketListener creates a new WebSocket stream handler (previously NewWebsocketsListener)
func NewWebSocketListenerWithContext ¶
func NewWebSocketListenerWithContext(host string, port uint16, ctx context.Context, opts ...ServerOptFunc) (Listener, error)
NewWebSocketListenerWithContext creates a new WebSocket stream handler with context
type ServerOptFunc ¶
type ServerOptFunc func(config *listener.ServerConfig)
Common server options that apply to all protocols
func WithBufferSize ¶
func WithBufferSize(size int) ServerOptFunc
WithBufferSize sets the channel buffer size for any protocol
func WithLogger ¶
func WithLogger(logger listener.Logger) ServerOptFunc
WithLogger sets a custom logger implementation
func WithMaxConnections ¶
func WithMaxConnections(max int) ServerOptFunc
WithMaxConnections sets the maximum number of concurrent connections
func WithMaxLength ¶
func WithMaxLength(length uint32) ServerOptFunc
WithMaxLength sets the maximum message length for any protocol
func WithTimeouts ¶
func WithTimeouts(read, write time.Duration) ServerOptFunc
WithTimeouts sets read and write timeouts for any protocol
func WithWebSocketBufferSizes ¶
func WithWebSocketBufferSizes(readSize, writeSize int) ServerOptFunc
WebSocket specific options
func WithWebSocketPath ¶
func WithWebSocketPath(path string) ServerOptFunc
type WebSocketConfig ¶
type WebSocketConfig struct {
ReadBufferSize int
WriteBufferSize int
Path string // URL path for the WebSocket endpoint
}
WebSocket specific configuration
Directories
¶
| Path | Synopsis |
|---|---|
|
example
|
|
|
quicclient
command
|
|
|
quiclistener
command
|
|
|
tcplistener
command
|
|
|
udpclient
command
|
|
|
udplistener
command
|
|
|
wslistener
command
|
|
