Documentation
¶
Overview ¶
Package aggstream provides the plumbing for aggregated JSON-lines streams: endpoints that multiplex per-environment events from the local environment and every remote environment over a single HTTP response, so the browser needs one connection regardless of environment count.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReconcileEnvironmentPollers ¶
func ReconcileEnvironmentPollers( ctx context.Context, lister RemoteEnvironmentLister, reconcileInterval time.Duration, streamLabel string, runPoller func(ctx context.Context, environmentID string), )
ReconcileEnvironmentPollers keeps one poller goroutine per enabled remote environment, re-listing periodically so environments added or removed while the stream is open are picked up without a reconnect. It returns when the stream context is canceled, after every poller has exited.
func Run ¶
func Run[T any]( ctx context.Context, encoder *json.Encoder, flush func(), buffer int, heartbeatInterval time.Duration, makeHeartbeat func() T, producers ...func(ctx context.Context, events chan<- T), )
Run drives a JSON-lines aggregated stream: it fans in events from the given producers over a single buffered channel and multiplexes them onto the response together with periodic heartbeats. It returns when the request context is canceled or the response writer fails.