Documentation
¶
Overview ¶
Package common provides shared types and utilities for server implementations.
Package common provides shared types and utilities for server implementations.
Package common provides shared types and utilities for server implementations.
Package common provides shared types and utilities for server implementations.
Index ¶
Constants ¶
const ( // WriteWait is time allowed to write a message to the peer. WriteWait = 15 * time.Second // PongWait is time allowed to read the next pong message from the peer. // Increased from 60s to 90s for better mobile network tolerance. PongWait = 90 * time.Second // PingPeriod is the interval for sending pings. Must be less than PongWait. PingPeriod = (PongWait * 9) / 10 // 81 seconds // MaxMessageSize is the maximum message size allowed from peer. // Must be larger than max_file_size_kb (10MB) to support file transfers. MaxMessageSize = 12 * 1024 * 1024 // 12MB (allows 10MB files + JSON overhead) // SendBufferSize is the send buffer size per client. // Increased from 256 to 1024 for handling burst events. SendBufferSize = 1024 // HeartbeatInterval is the application-level heartbeat interval. HeartbeatInterval = 30 * time.Second )
WebSocket timing constants. These are tuned for mobile network tolerance.
Variables ¶
var ErrBufferFull = errors.New("send buffer full")
ErrBufferFull is returned when the send buffer is full.
var ErrClosed = errors.New("closed")
ErrClosed is returned when operations are attempted on a closed resource.
Functions ¶
func EventNotificationMethod ¶
EventNotificationMethod returns the JSON-RPC method name for an event type.
func EventToJSONRPCNotification ¶
EventToJSONRPCNotification converts a domain event to a JSON-RPC notification. This is used to send events to JSON-RPC clients.
func ExtractEventPayload ¶
ExtractEventPayload extracts the payload field from event JSON.
Types ¶
type Closer ¶
type Closer interface {
// Close closes the resource.
Close() error
// Done returns a channel that's closed when the resource is closed.
Done() <-chan struct{}
}
Closer is an interface for closable resources.
type SendBuffer ¶
type SendBuffer struct {
// contains filtered or unexported fields
}
SendBuffer provides a thread-safe buffered channel for sending messages. It's designed for high-throughput scenarios like WebSocket message delivery.
func NewSendBuffer ¶
func NewSendBuffer(id string, capacity int) *SendBuffer
NewSendBuffer creates a new send buffer with the specified capacity.
func (*SendBuffer) Channel ¶
func (b *SendBuffer) Channel() <-chan []byte
Channel returns the underlying channel for reading.
func (*SendBuffer) Done ¶
func (b *SendBuffer) Done() <-chan struct{}
Done returns a channel that's closed when the buffer is closed.
func (*SendBuffer) IsClosed ¶
func (b *SendBuffer) IsClosed() bool
IsClosed returns true if the buffer is closed.
func (*SendBuffer) Send ¶
func (b *SendBuffer) Send(data []byte) error
Send queues data for sending. Returns ErrBufferFull if the buffer is full, or ErrClosed if the buffer has been closed.
type StatusProvider ¶
type StatusProvider interface {
// GetAgentStatus returns the current agent status (e.g., "idle", "running").
GetAgentStatus() string
// GetUptimeSeconds returns the server uptime in seconds.
GetUptimeSeconds() int64
}
StatusProvider provides status information for heartbeat events. This interface is implemented by the application to provide runtime status.