Documentation
¶
Index ¶
- type BuildEventPublisher
- type Conn
- type Envelope
- type Handler
- type Hub
- func (h *Hub) BroadcastToTopic(topicID uuid.UUID, env Envelope)
- func (h *Hub) ClearTopicBuffer(topicID uuid.UUID)
- func (h *Hub) ConnCount() int
- func (h *Hub) OnTopicSubscriptionChange(onFirst func(uuid.UUID), onLast func(uuid.UUID))
- func (h *Hub) Register(conn *Conn)
- func (h *Hub) SendToConnection(connID string, env Envelope)
- func (h *Hub) Subscribe(conn *Conn, topicID uuid.UUID)
- func (h *Hub) TopicConnCount(topicID uuid.UUID) int
- func (h *Hub) Unregister(conn *Conn)
- type MessageHandler
- type PubSub
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BuildEventPublisher ¶
type BuildEventPublisher struct {
// contains filtered or unexported fields
}
BuildEventPublisher adapts PubSub to the builder.EventPublisher interface.
func NewBuildEventPublisher ¶
func NewBuildEventPublisher(ps *PubSub, hub *Hub) *BuildEventPublisher
NewBuildEventPublisher creates a BuildEventPublisher.
func (*BuildEventPublisher) PublishBuildEvent ¶
func (p *BuildEventPublisher) PublishBuildEvent(ctx context.Context, agentID, buildID uuid.UUID, status, errMsg string)
PublishBuildEvent publishes an agent build lifecycle event.
func (*BuildEventPublisher) PublishBuildLogLine ¶
func (p *BuildEventPublisher) PublishBuildLogLine(ctx context.Context, agentID, buildID uuid.UUID, seq int64, stream, line string)
PublishBuildLogLine publishes a single build log line for real-time streaming. seq is a monotonic counter per build (across both sol and docker streams); the frontend uses it to dedupe against a REST snapshot of the persisted log.
type Conn ¶
type Conn struct {
ID string
UserID uuid.UUID
Email string
// contains filtered or unexported fields
}
Conn wraps a WebSocket connection with user identity and a send buffer.
func (*Conn) Close ¶
func (c *Conn) Close()
Close closes the send channel, causing WritePump to exit.
func (*Conn) ReadPump ¶
func (c *Conn) ReadPump(ctx context.Context, handler MessageHandler)
ReadPump reads messages from the WebSocket and dispatches to handler. Blocks until the connection closes or ctx is cancelled.
func (*Conn) SendEnvelope ¶
SendEnvelope marshals and enqueues an envelope.
type Envelope ¶
type Envelope struct {
Type string `json:"type"`
RequestID string `json:"requestId,omitempty"`
TopicID string `json:"topicId,omitempty"`
Payload json.RawMessage `json:"payload,omitempty"`
}
Envelope is the JSON wire format for all WebSocket messages.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler routes inbound WebSocket messages. Subscriptions are no longer client-initiated — the WS upgrade handler auto-subscribes new connections to every agent the user is a member of, based on durable agent_members state. Any inbound message from the client is therefore unexpected; we log and reject so misbehaving clients don't silently drift.
func NewHandler ¶
NewHandler creates a new inbound message handler.
func (*Handler) HandleMessage ¶
HandleMessage rejects all inbound messages. The WS is server→client only.
type Hub ¶
type Hub struct {
// contains filtered or unexported fields
}
Hub manages WebSocket connections and topic subscriptions. A single connection can be subscribed to many topics at once — typically every agent the user is a member of, wired up at WS-accept time.
func (*Hub) BroadcastToTopic ¶
BroadcastToTopic sends an envelope to all connections subscribed to a topic. Events are also buffered per topic so late subscribers can replay missed events.
func (*Hub) ClearTopicBuffer ¶
ClearTopicBuffer removes the replay buffer for a topic. Called after a terminal event (build complete/failed) since replay is no longer needed.
func (*Hub) OnTopicSubscriptionChange ¶
OnTopicSubscriptionChange sets callbacks for when the first local connection subscribes to a topic and when the last unsubscribes. Used by PubSub to manage Redis subscriptions.
func (*Hub) SendToConnection ¶
SendToConnection sends an envelope to a specific connection by ID.
func (*Hub) Subscribe ¶
Subscribe adds the connection to the given topic if not already subscribed. Pre-existing topic subscriptions on this connection are not affected — Subscribe is additive, so the WS accept handler can call it in a loop over the user's member agents without disturbing anything else. Replays any buffered events for the topic to the newly-subscribed connection.
func (*Hub) TopicConnCount ¶
TopicConnCount returns the number of connections subscribed to a topic.
func (*Hub) Unregister ¶
Unregister removes a connection and all its topic subscriptions, firing onLastUnsubscribe for any topic that's now empty.
type MessageHandler ¶
MessageHandler processes an inbound WebSocket message from a client.
type PubSub ¶
type PubSub struct {
// contains filtered or unexported fields
}
PubSub delivers real-time envelopes to local WebSocket subscribers via the Hub. This is the single-instance implementation. For multi-instance fan-out (e.g. via Redis pub/sub), replace or extend this with a cross-process transport.
func (*PubSub) ClearTopicBuffer ¶
ClearTopicBuffer removes the replay buffer for a topic. Call after terminal events (run complete, build complete) so reconnecting clients don't replay stale streaming events.