Graphorin API reference v0.12.1
Graphorin API reference / @graphorin/server / / WsDispatcher
Interface: WsDispatcher
Defined in: packages/server/src/ws/dispatcher.ts:145
Public surface of the dispatcher.
Stable
Properties
| Property | Modifier | Type | Defined in |
|---|---|---|---|
replayBuffer | readonly | ReplayBuffer | packages/server/src/ws/dispatcher.ts:147 |
sanitizer | readonly | DeliveryCommentarySanitizer | packages/server/src/ws/dispatcher.ts:146 |
Methods
emit()
emit(subject, frame): void;Defined in: packages/server/src/ws/dispatcher.ts:178
Push an event into the dispatcher. Goes through the sanitizer, validates against the protocol schema, persists into the replay buffer, and fans out to every matching active subscription.
Parameters
| Parameter | Type |
|---|---|
subject | string |
frame | BareEventFrame |
Returns
void
emitLifecycle()
emitLifecycle(
subscriptionId,
status,
reason?): void;Defined in: packages/server/src/ws/dispatcher.ts:180
Push a lifecycle frame to a single subscription.
Parameters
| Parameter | Type |
|---|---|
subscriptionId | string |
status | "running" | "completed" | "failed" | "aborted" | "paused" |
reason? | string |
Returns
void
listForSubscriber()
listForSubscriber(subscriberId): readonly WsSubscriptionSnapshot[];Defined in: packages/server/src/ws/dispatcher.ts:186
List active subscriptions for a given subscriber (diagnostics).
Parameters
| Parameter | Type |
|---|---|
subscriberId | string |
Returns
readonly WsSubscriptionSnapshot[]
registerSubscriber()
registerSubscriber(handle): {
unregister: void;
};Defined in: packages/server/src/ws/dispatcher.ts:152
Register a subscriber (one per WebSocket connection). unregister is called on close.
Parameters
| Parameter | Type |
|---|---|
handle | WsSubscriberHandle |
Returns
{
unregister: void;
}| Name | Type | Defined in |
|---|---|---|
unregister() | () => void | packages/server/src/ws/dispatcher.ts:152 |
shutdown()
shutdown(): void;Defined in: packages/server/src/ws/dispatcher.ts:190
Clear in-memory state (used during graceful shutdown).
Returns
void
size()
size(): {
subscribers: number;
subscriptions: number;
};Defined in: packages/server/src/ws/dispatcher.ts:188
Returns
{
subscribers: number;
subscriptions: number;
}| Name | Type | Defined in |
|---|---|---|
subscribers | number | packages/server/src/ws/dispatcher.ts:188 |
subscriptions | number | packages/server/src/ws/dispatcher.ts:188 |
snapshotSubscription()
snapshotSubscription(subscriptionId):
| WsSubscriptionSnapshot
| undefined;Defined in: packages/server/src/ws/dispatcher.ts:187
Parameters
| Parameter | Type |
|---|---|
subscriptionId | string |
Returns
| WsSubscriptionSnapshot | undefined
subscribe()
subscribe(input): SubscribeResult;Defined in: packages/server/src/ws/dispatcher.ts:165
Open a new subscription for an active subscriber. Returns either the subscription snapshot + replayed-event count or a typed failure reason the caller maps to the appropriate close code / RPC error.
E-02 (S-15/8): with deferReplay: true the buffered frames are captured but NOT delivered; the caller must invoke the returned dispatchReplay() once its acknowledgement (e.g. the subscribe RPC reply) is on the wire, so clients that key their subscription map off that reply do not drop the replayed frames.
Parameters
| Parameter | Type |
|---|---|
input | { deferReplay?: boolean; sinceEventId?: string; subject: string; subscriberId: string; subscriptionId: string; } |
input.deferReplay? | boolean |
input.sinceEventId? | string |
input.subject | string |
input.subscriberId | string |
input.subscriptionId | string |
Returns
unsubscribe()
unsubscribe(subscriptionId): boolean;Defined in: packages/server/src/ws/dispatcher.ts:172
Parameters
| Parameter | Type |
|---|---|
subscriptionId | string |
Returns
boolean