Documentation
¶
Overview ¶
Package rpcstream holds helpers shared by the engine's streaming RPC handlers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrClosed = errors.New("stream is closed")
ErrClosed is returned by Send once the handler that owns the stream has returned.
Functions ¶
Types ¶
type Sender ¶
type Sender[T any] struct { // contains filtered or unexported fields }
Sender serializes sends on a server stream and rejects sends once the owning handler has returned.
Handlers hand their stream to other goroutines (the dispatcher sends assigned actions from message queue consumers, subscriptions send from fan-out goroutines). The HTTP/2 server panics on a write that arrives after the handler has returned, so every handler that shares its stream must wrap it in a Sender and defer Close: Close turns every later Send into ErrClosed and does not return while a Send is still writing. A Send to a peer that has stopped reading is interrupted after a short grace period, so a handler can always return.