sse

package
v0.4.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 22, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentDiedCallback

type AgentDiedCallback func(workspaceID string)

AgentDiedCallback is invoked when an upstream SSE stream ends after at least one byte of data has been received, signaling that the agent process died mid-stream (OOM, crash, or restart). The tracker cannot distinguish a real death from a normal opencode restart — see US-44.1a/c for the accepted false-positive tradeoff.

type InferenceCallback

type InferenceCallback func(workspaceID, modelID, providerID string, inputTokens, outputTokens int64, costDollars float64)

type RawEventCallback

type RawEventCallback func(workspaceID, eventType, rawData string)

type ReconnectCallback

type ReconnectCallback func(workspaceID, podIP, password string)

ReconnectCallback is called at the start of each connection attempt, after the pod IP and password are resolved but before the SSE stream is opened. podIP is the raw IP (no port). password is the workspace password (used as Bearer token on the agentd admin port). Intended use: query /v1/statusz to reconcile any sessions that went idle while the SSE connection was down, and drain their queues.

type SessionIdleCallback

type SessionIdleCallback func(workspaceID, sessionID string)

type SessionMetricsRecorder

type SessionMetricsRecorder interface {
	RecordSessionCompleted(workspaceID string, durationSeconds float64)
}

type Tracker

type Tracker struct {
	HttpClient *http.Client
	Logger     pkginterfaces.LoggerInterface
	// contains filtered or unexported fields
}

func NewTracker

func NewTracker(
	httpClient *http.Client,
	logger pkginterfaces.LoggerInterface,
	onSessionIdle SessionIdleCallback,
) *Tracker

func (*Tracker) DispatchProperties

func (t *Tracker) DispatchProperties(workspaceID, eventType string, props json.RawMessage)

func (*Tracker) EnsureWatching

func (t *Tracker) EnsureWatching(workspaceID string)

func (*Tracker) ProcessEvent

func (t *Tracker) ProcessEvent(workspaceID, data string)

func (*Tracker) SetIdleTimeout

func (t *Tracker) SetIdleTimeout(d time.Duration)

SetIdleTimeout overrides the SSE idle timeout. Primarily for tests; production uses the package default (sseIdleTimeout).

func (*Tracker) SetOnAgentDied

func (t *Tracker) SetOnAgentDied(cb AgentDiedCallback)

func (*Tracker) SetOnInference

func (t *Tracker) SetOnInference(cb InferenceCallback)

func (*Tracker) SetOnRawEvent

func (t *Tracker) SetOnRawEvent(callback RawEventCallback)

func (*Tracker) SetOnReconnect

func (t *Tracker) SetOnReconnect(callback ReconnectCallback)

func (*Tracker) SetOnSessionActive

func (t *Tracker) SetOnSessionActive(callback SessionIdleCallback)

func (*Tracker) SetPasswordGetter

func (t *Tracker) SetPasswordGetter(provider interfaces.WorkspacePasswordProvider)

func (*Tracker) SetPodIPResolver

func (t *Tracker) SetPodIPResolver(resolver func(workspaceID string) string)

func (*Tracker) SetSessionMetrics

func (t *Tracker) SetSessionMetrics(r SessionMetricsRecorder)

func (*Tracker) Stop

func (t *Tracker) Stop()

func (*Tracker) StopWatching

func (t *Tracker) StopWatching(workspaceID string)

func (*Tracker) SubscribeDrain

func (t *Tracker) SubscribeDrain(
	workspaceID string,
	onIdle func(workspaceID, sessionID string),
	onActive func(workspaceID, sessionID string),
) (cancel func())

func (*Tracker) SubscriptionCount

func (t *Tracker) SubscriptionCount() int

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL