Skip to content

Documentation / @super-line/server / CollectionHost

Interface: CollectionHost ​

Defined in: collections/types.ts:69

What the server provides to the Collection runtime. Each entry is a capability, not a raw handle: the runtime never learns that publishing needs encoding, that echo-break is spelled nd, or that observation has a cost. That is the difference between this module having an interface and merely having a file.

Properties ​

channels ​

channels: object

Defined in: collections/types.ts:85

The channel registry rooms and topics already share. Only CRDT documents use it; rows never do.

join() ​

join(conn, channel): Awaitable<void>

Sync when the node already holds the channel, async when it must subscribe the Adapter first.

Parameters ​
conn ​

CollectionConn

channel ​

string

Returns ​

Awaitable<void>

leave() ​

leave(conn, channel): void

Parameters ​
conn ​

CollectionConn

channel ​

string

Returns ​

void

membersOf() ​

membersOf(channel): Set<CollectionConn> | undefined

Parameters ​
channel ​

string

Returns ​

Set<CollectionConn> | undefined


cluster ​

cluster: Cluster

Defined in: collections/types.ts:83

Node identity on the wire. Owns stamping + detection; the delivery policy stays here (see Cluster).

Methods ​

dispatch() ​

dispatch(conn, id, info, terminal, onError?): Promise<void>

Defined in: collections/types.ts:75

The shared op spine: run host + plugin middleware, then terminal; on a throw, route to onError, send the client an err frame, and fire the host's error hook. Collections pass their own onError so the failure surfaces as a collection.* tap rather than a generic msg.response.

Parameters ​

conn ​

CollectionConn

id ​

number

info ​
conn ​

CollectionConn

kind ​

"subscribe" | "request"

name ​

string

terminal ​

() => Promise<void>

onError? ​

(error) => void

Returns ​

Promise<void>


encode() ​

encode(frame): string | Uint8Array<ArrayBufferLike>

Defined in: collections/types.ts:102

Encode a frame for sendRaw. Needed only by the self CRDT path, which fans out to local subscribers without a node hop: it encodes once and passes one buffer to N connections. Everything that does cross a node boundary goes through Cluster.broadcast, which encodes and stamps for itself — so a frame encoded here deliberately carries no node id, because it was never published.

Parameters ​

frame ​

object

Returns ​

string | Uint8Array<ArrayBufferLike>


tap() ​

tap(event): void

Defined in: collections/types.ts:95

Emit an inspector/plugin tap. Takes a thunk, not an event: building a tap payload costs a snapshot, and with no plugin tapping, the thunk is never called. Collections therefore never guard their own emits.

Parameters ​

event ​

() => InspectorEvent

Returns ​

void

Released under the MIT License.