API Reference
classes
Wakersubscriptionmanager

@coasys/ad4m / Exports / WakerSubscriptionManager

Class: WakerSubscriptionManager

Table of contents

Constructors

Properties

Methods

Constructors

constructor

• new WakerSubscriptionManager(options)

Parameters

NameType
optionsWakerSubscriptionManagerOptions

Defined in

core/src/perspectives/WakerSubscriptionManager.ts:140 (opens in a new tab)

Properties

QuerySubscriptionProxyCtor

• Private QuerySubscriptionProxyCtor: any

Defined in

core/src/perspectives/WakerSubscriptionManager.ts:113 (opens in a new tab)


activeSubscriptions

• Private activeSubscriptions: Map<string, WakerSubscription>

Defined in

core/src/perspectives/WakerSubscriptionManager.ts:119 (opens in a new tab)


debounceMs

• Private debounceMs: number

Defined in

core/src/perspectives/WakerSubscriptionManager.ts:110 (opens in a new tab)


debounceTimers

• Private debounceTimers: Map<string, Timeout>

Defined in

core/src/perspectives/WakerSubscriptionManager.ts:135 (opens in a new tab)


epoch

• Private epoch: number = 0

Cancellation tokens for in-flight subscribe() calls.

subscribe() awaits proxy.subscribe() and proxy.initialized; a dispose() / disposeAll() landing during either await used to leave a live subscription behind, because nothing stopped the resumed call from registering the proxy in proxies / activeSubscriptions afterwards. epoch is bumped by disposeAll() (which cannot enumerate in-flight ids), generations per id by dispose() and by each new subscribe().

Defined in

core/src/perspectives/WakerSubscriptionManager.ts:133 (opens in a new tab)


generations

• Private generations: Map<string, number>

Defined in

core/src/perspectives/WakerSubscriptionManager.ts:134 (opens in a new tab)


logger

• Private logger: WakerLogger

Defined in

core/src/perspectives/WakerSubscriptionManager.ts:109 (opens in a new tab)


onPersist

• Private Optional onPersist: (subscriptions: WakerSubscription[], seenMessages: Record<string, string[]>) => void

Type declaration

▸ (subscriptions, seenMessages): void

Parameters
NameType
subscriptionsWakerSubscription[]
seenMessagesRecord<string, string[]>
Returns

void

Defined in

core/src/perspectives/WakerSubscriptionManager.ts:112 (opens in a new tab)


onWake

• Private onWake: (sub: WakerSubscription, result: any, mentions?: MentionMessage[]) => void

Type declaration

▸ (sub, result, mentions?): void

Parameters
NameType
subWakerSubscription
resultany
mentions?MentionMessage[]
Returns

void

Defined in

core/src/perspectives/WakerSubscriptionManager.ts:111 (opens in a new tab)


pendingSubscriptions

• Private pendingSubscriptions: Map<string, WakerSubscription>

Subscriptions the executor rejected, waiting to be re-attempted.

Defined in

core/src/perspectives/WakerSubscriptionManager.ts:121 (opens in a new tab)


perspectiveClient

• Private perspectiveClient: any

Defined in

core/src/perspectives/WakerSubscriptionManager.ts:108 (opens in a new tab)


previousSeenMessages

• Private previousSeenMessages: Record<string, string[]>

Defined in

core/src/perspectives/WakerSubscriptionManager.ts:114 (opens in a new tab)


proxies

• Private proxies: Map<string, any>

Defined in

core/src/perspectives/WakerSubscriptionManager.ts:118 (opens in a new tab)


retryPendingMs

• Private retryPendingMs: number

Defined in

core/src/perspectives/WakerSubscriptionManager.ts:115 (opens in a new tab)


retryTimer

• Private retryTimer: Timeout = null

Defined in

core/src/perspectives/WakerSubscriptionManager.ts:122 (opens in a new tab)


seenMessages

• Private seenMessages: Map<string, Set<string>>

Per-subscription set of already-processed message addresses (for mention subs) or serialized result hash (for channel-messages subs).

Defined in

core/src/perspectives/WakerSubscriptionManager.ts:138 (opens in a new tab)


subscribeTimeoutMs

• Private subscribeTimeoutMs: number

Defined in

core/src/perspectives/WakerSubscriptionManager.ts:116 (opens in a new tab)

Methods

beginAttempt

▸ Private beginAttempt(id): Object

A token identifying this attempt at subscribing id.

Parameters

NameType
idstring

Returns

Object

NameType
epochnumber
gennumber

Defined in

core/src/perspectives/WakerSubscriptionManager.ts:153 (opens in a new tab)


dispose

▸ dispose(id, persist?): void

Dispose a single subscription.

Parameters

NameTypeDefault valueDescription
idstringundefined-
persistbooleantrue— if false, skip calling onPersist (used during batch cleanup).

Returns

void

Defined in

core/src/perspectives/WakerSubscriptionManager.ts:419 (opens in a new tab)


disposeAll

▸ disposeAll(): void

Dispose all active subscriptions and drop anything still pending.

Returns

void

Defined in

core/src/perspectives/WakerSubscriptionManager.ts:443 (opens in a new tab)


getActive

▸ getActive(): WakerSubscription[]

Get all active subscriptions.

Returns

WakerSubscription[]

Defined in

core/src/perspectives/WakerSubscriptionManager.ts:458 (opens in a new tab)


getPending

▸ getPending(): WakerSubscription[]

Subscriptions that were rejected and are waiting to be re-attempted.

Returns

WakerSubscription[]

Defined in

core/src/perspectives/WakerSubscriptionManager.ts:411 (opens in a new tab)


has

▸ has(id): boolean

Check if a subscription exists.

Parameters

NameType
idstring

Returns

boolean

Defined in

core/src/perspectives/WakerSubscriptionManager.ts:463 (opens in a new tab)


isStale

▸ Private isStale(id, token): boolean

Whether this attempt has been superseded by a dispose or a newer one.

Parameters

NameType
idstring
tokenObject
token.epochnumber
token.gennumber

Returns

boolean

Defined in

core/src/perspectives/WakerSubscriptionManager.ts:160 (opens in a new tab)


persist

▸ Private persist(): void

Returns

void

Defined in

core/src/perspectives/WakerSubscriptionManager.ts:467 (opens in a new tab)


retryPending

▸ retryPending(): Promise<void>

Re-attempt every subscription the executor rejected. Each attempt that fails puts itself back into the pending set and re-arms the timer, so an agent that asked to be subscribed ends up enrolled once the executor can accept the query.

Returns

Promise<void>

Defined in

core/src/perspectives/WakerSubscriptionManager.ts:385 (opens in a new tab)


scheduleRetry

▸ Private scheduleRetry(): void

Arm the re-attempt timer if pending subscriptions are waiting.

Returns

void

Defined in

core/src/perspectives/WakerSubscriptionManager.ts:369 (opens in a new tab)


subscribe

▸ subscribe(sub): Promise<void>

Create a live SPARQL subscription. If a subscription with the same id already exists, it is disposed first.

Parameters

NameType
subWakerSubscription

Returns

Promise<void>

Defined in

core/src/perspectives/WakerSubscriptionManager.ts:168 (opens in a new tab)