Skip to content

Documentation / @super-line/server / Cluster

Interface: Cluster

Defined in: cluster.ts:46

Node identity on the wire — a thin module over the Adapter that owns the one fact every cross-node frame carries: which node published it. It stamps that id outbound, encodes/decodes through the Serializer, and reports own inbound, so no call site hand-rolls frame.nd === instanceId.

It owns detection, never policy. This server has two local-delivery strategies; both are correct, and which one you picked decides what own means for you:

  • deliver-at-source — the cluster bus, plugin channels, and row-collection relay fan out to local listeners at publish time and then drop the looped-back copy (if (own) return).
  • deliver-on-receipt — CRDT document relay does not deliver on its own store onChange. It publishes, and the Adapter's loopback is what fans the frame out to local subscribers. It forwards regardless of own, using own only to skip re-applying its own delta. A Cluster that quietly filtered own-messages would break every CRDT client's local delivery — so this one hands own over and stays out of it.

The id is stamped into the frame rather than wrapped in an envelope, so an adapter payload remains a valid client frame and the sendRaw passthrough above keeps working. That is why NODE appears on client-visible frame types, declared there as ignored by clients.

Distinct from the Adapter (carries the bytes; guarantees the loopback) and from a CRDT replica origin (a per-writer id that survives relay, and so cannot stand in for node identity).

Methods

broadcast()

broadcast(channel, frame): void

Defined in: cluster.ts:48

Stamp this node's id into frame, encode once, and publish. The Adapter loops it back to us as well.

Parameters

channel

string

frame

object

Returns

void


receive()

receive(payload): ClusterMessage | undefined

Defined in: cluster.ts:50

Decode an inbound payload and report who published it. undefined when the payload does not decode.

Parameters

payload

string | Uint8Array<ArrayBufferLike>

Returns

ClusterMessage | undefined

Released under the MIT License.