Documentation
¶
Index ¶
- func CountWorkerGoroutines() int
- func ForwardLines(ctx context.Context, hub *Hub, lines <-chan string)
- func ForwardLogJSON(ctx context.Context, hub *Hub, logs <-chan LogMessage)
- func ForwardLogJSONBatched(ctx context.Context, hub *Hub, logs <-chan LogMessage, maxBatch int, ...)
- func NormalizeContainerLine(raw string) (level string, msg string, timestamp string)
- func NormalizeProjectLine(raw string) (level, service, msg, timestamp string)
- func NowRFC3339() string
- func ProxyHTTP(w http.ResponseWriter, r *http.Request, remoteWS string, header http.Header) error
- func ServeClientWithOnRemove(ctx context.Context, hub *Hub, conn *websocket.Conn, onRemove func())
- type Client
- type Hub
- type LogMessage
- type WebSocketMetrics
- func (m *WebSocketMetrics) Connections() []systemtypes.WebSocketConnectionInfo
- func (m *WebSocketMetrics) RegisterConnection(info systemtypes.WebSocketConnectionInfo) string
- func (m *WebSocketMetrics) Snapshot() systemtypes.WebSocketMetricsSnapshot
- func (m *WebSocketMetrics) UnregisterConnection(id string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CountWorkerGoroutines ¶
func CountWorkerGoroutines() int
CountWorkerGoroutines returns a best-effort count of websocket worker goroutines belonging to this package. Intended for diagnostics endpoints only.
func ForwardLines ¶
ForwardLines forwards plain text lines to the hub.
func ForwardLogJSON ¶
func ForwardLogJSON(ctx context.Context, hub *Hub, logs <-chan LogMessage)
ForwardLogJSON sends each LogMessage as its own JSON object frame.
func ForwardLogJSONBatched ¶
func ForwardLogJSONBatched(ctx context.Context, hub *Hub, logs <-chan LogMessage, maxBatch int, flushInterval time.Duration)
ForwardLogJSONBatched batches log messages into a JSON array frame to reduce frame count. Flushes when maxBatch reached or flushInterval elapsed.
func NormalizeContainerLine ¶
NormalizeContainerLine parses a raw container log line into level + cleaned message. It extracts Docker's timestamp if present (when timestamps=true in Docker API).
func NormalizeProjectLine ¶
NormalizeProjectLine additionally extracts service (pattern: service | message). Returns level, service, message, timestamp (RFC3339Nano) — timestamp may be empty.
func NowRFC3339 ¶
func NowRFC3339() string
func ServeClientWithOnRemove ¶
ServeClientWithOnRemove registers the client with the hub and starts read/write pumps. Caller is responsible for creating/closing the websocket.Conn. If onRemove is non-nil, it is invoked when the client is removed from the hub.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents a single WebSocket connection.
type Hub ¶
type Hub struct {
// contains filtered or unexported fields
}
func (*Hub) SetOnActive ¶
func (h *Hub) SetOnActive(fn func())
func (*Hub) SetOnEmpty ¶
func (h *Hub) SetOnEmpty(fn func())
func (*Hub) SetOnFirstClient ¶
func (h *Hub) SetOnFirstClient(fn func())
type LogMessage ¶
type WebSocketMetrics ¶ added in v2.1.0
type WebSocketMetrics struct {
// contains filtered or unexported fields
}
WebSocketMetrics tracks active WebSocket connections and their counts.
func NewWebSocketMetrics ¶ added in v2.1.0
func NewWebSocketMetrics() *WebSocketMetrics
NewWebSocketMetrics creates a new WebSocketMetrics instance.
func (*WebSocketMetrics) Connections ¶ added in v2.1.0
func (m *WebSocketMetrics) Connections() []systemtypes.WebSocketConnectionInfo
Connections returns a snapshot of all tracked WebSocket connections.
func (*WebSocketMetrics) RegisterConnection ¶ added in v2.1.0
func (m *WebSocketMetrics) RegisterConnection(info systemtypes.WebSocketConnectionInfo) string
RegisterConnection adds a connection to the tracker and increments the appropriate kind counter. Returns the assigned connection ID.
func (*WebSocketMetrics) Snapshot ¶ added in v2.1.0
func (m *WebSocketMetrics) Snapshot() systemtypes.WebSocketMetricsSnapshot
Snapshot returns a point-in-time copy of the active connection counts.
func (*WebSocketMetrics) UnregisterConnection ¶ added in v2.1.0
func (m *WebSocketMetrics) UnregisterConnection(id string)
UnregisterConnection removes a connection from the tracker and decrements the appropriate kind counter.