Documentation
¶
Index ¶
Constants ¶
const ( // Client to Server message kinds MessageKindSubscribe = "s" // Subscribe to a topic pattern MessageKindUnsubscribe = "u" // Unsubscribe from a topic pattern MessageKindUnsubscribeAll = "U" // Unsubscribe from all topics // Server to Client message kinds MessageKindAck = "a" // Positive acknowledgment of client request MessageKindNack = "n" // Negative acknowledgment (error response) // Bidirectional - Event messages have no "k" field // They are identified by the presence of "t" (topic) and "d" (data) fields MessageKindEvent = "" // Event message )
Message kind constants for the Vinculum WebSocket protocol. These correspond to the "k" (kind) field in wire messages.
Variables ¶
This section is empty.
Functions ¶
func ExtractTrace ¶ added in v0.10.0
func ExtractTrace(ctx context.Context, msg WireMessage) context.Context
ExtractTrace extracts trace context from msg.Headers and returns a derived context. If Headers is empty or no propagator is configured, the original ctx is returned unchanged.
func HeadersFromContext ¶ added in v0.10.0
HeadersFromContext extracts propagation headers from ctx as a map, or nil if empty. This is used by the server's pre-allocated eventMsg map to avoid creating a WireMessage.
func InjectTrace ¶ added in v0.10.0
func InjectTrace(ctx context.Context, msg *WireMessage)
InjectTrace injects trace context from ctx into msg.Headers using the global propagator. If no propagator is configured (the default no-op), this is a no-op and Headers is unchanged.
Types ¶
type WireMessage ¶
type WireMessage struct {
Kind string `json:"k,omitempty"` // Message kind/type (see MessageKind constants)
Topic string `json:"t,omitempty"` // Topic or topic pattern
Data any `json:"d,omitempty"` // Event data/payload
Id any `json:"i,omitempty"` // Message identifier for request/response matching
Error string `json:"e,omitempty"` // Error message (used with NACK)
Headers map[string]string `json:"h,omitempty"` // Generic headers (e.g. W3C trace context)
}
WireMessage represents the JSON structure for WebSocket messages. This follows the Vinculum WebSocket protocol with short field names for efficiency.