Documentation
¶
Overview ¶
Package stream is grain's server->browser push channel. A per-pubkey hub fans live messages (login-hydration live-sync #87, streaming fetch #77) out to a user's open pages over SSE; connections register on connect and drop on disconnect. Lifecycle callbacks let a consumer start work (e.g. the own-event subscription) only while a page is actually open.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Hub ¶
type Hub struct {
// contains filtered or unexported fields
}
Hub fans push messages out to a user's open browser pages, keyed by pubkey.
func (*Hub) HasClients ¶
HasClients reports whether pubkey currently has any open connection.
func (*Hub) Push ¶
Push delivers a message to all of pubkey's open connections. Non-blocking: a connection whose buffer is full drops the message rather than stalling others.
func (*Hub) Register ¶
Register adds a connection for pubkey and returns its message channel plus an unregister func to call on disconnect.
func (*Hub) SetLifecycle ¶
SetLifecycle wires callbacks fired when a pubkey gains its first / loses its last open connection — so the live-sync subscription runs only while a page is open. Either may be nil.