Documentation
¶
Overview ¶
Package contractstream is the API-side on-demand proxy of a pod's ABI contract stream (US-69.10, design 0055 S3/D1-B): one upstream connection per workspace while ≥1 browser subscriber is attached, fanning raw StreamFrames out to every subscriber. Browsers run the stamped-snapshot client rule themselves — this proxy forwards frames, it never folds.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FrameSource ¶
type FrameSource interface {
Frames() <-chan *abiv1.StreamFrame
Err() error
}
FrameSource is one live pod Events connection: frames until the channel closes or ctx is canceled (reconnect is the Manager's decision).
func ConnectStream ¶
func ConnectStream(ctx context.Context, baseURL, password string) (FrameSource, error)
ConnectStream is the default FrameSource factory: the generated connect client's Events op over Basic auth.
type Logger ¶
type Logger interface {
Warn(msg string, keysAndValues ...interface{})
}
Logger is the minimal seam (the API's LoggerInterface satisfies it).
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager owns one refcounted pod stream per workspace.
func NewManager ¶
func NewManager(resolve Resolve, logger Logger, connect func(ctx context.Context, baseURL, password string) (FrameSource, error)) *Manager
NewManager builds the manager. connect is injectable for tests; nil uses the default connect-stream source.
func (*Manager) SetOnUpstreamChange ¶ added in v0.27.0
SetOnUpstreamChange wires the optional upstream-lifecycle hook (the metrics seam — a prometheus gauge in the handler layer; the package stays import-clean). Fires open=true when a workspace's upstream is created (first attach) and open=false when it is torn down (last detach). Must be set before serving; read under mu.
func (*Manager) Subscribe ¶
Subscribe attaches one browser connection to the workspace's stream, creating the upstream on first attach. The returned channel carries frames and possibly one Resync (channel-closed after). The unsubscribe func must be called exactly once; the upstream disconnects on last detach (D1-B scale-to-zero).