Перейти к содержимому
Русский

ClusterSingletonProxy

Это содержимое пока не доступно на вашем языке.

Defined in: src/cluster/singleton/ClusterSingletonProxy.ts:24

Location-transparent handle to a cluster-wide singleton. Every call to tell looks up the current host and forwards to that node’s ClusterSingletonManager (via direct tell if local, via envelope if remote). Messages sent before the cluster has a host are buffered and drained when the first LeaderChanged event fires.

The proxy extends ActorRef so it can be passed anywhere an ActorRef is expected (e.g. as a sender for ask patterns). It is not backed by a real actor — it is a thin forwarder.

TCommand

new ClusterSingletonProxy<TCommand>(cluster, key, localManager, role?, bufferSize?): ClusterSingletonProxy<TCommand>

Defined in: src/cluster/singleton/ClusterSingletonProxy.ts:34

Cluster

SingletonKey<TCommand>

() => ActorRef<unknown> | null

This node’s manager, resolved per delivery rather than captured. A proxy handed out by ClusterSingleton.ref predates any local start() — and a start() may follow on this node later — so a captured ref would either be impossible to obtain or permanently stale.

string | undefined

Role restriction, if any — must be the same one the managers were started with, or this proxy and they disagree about who hosts. Defaults to the key’s, which is why the key carries it.

number = DEFAULT_BUFFER_SIZE

Cap on the no-host buffer. See DEFAULT_BUFFER_SIZE.

ClusterSingletonProxy<TCommand>

ActorRef.constructor

droppedCount: number = 0

Defined in: src/cluster/singleton/ClusterSingletonProxy.ts:32

Messages dropped because the no-host buffer was full — useful for metrics.


readonly path: ActorPath

Defined in: src/cluster/singleton/ClusterSingletonProxy.ts:25

ActorRef.path

ask<TResponse>(message, timeoutMs?): Promise<TResponse>

Defined in: src/ActorRef.ts:77

Request/response — send message and await the recipient’s reply. The framework synthesises a one-shot reply ref, injects it as both the sender slot and as message.replyTo, and resolves the returned promise with the first reply (or rejects with AskTimeoutError).

The caller never specifies replyTo on the message — the OmitReplyTo type subtracts it from the parameter type if the recipient declares it.

const value = await counter.ask<number>({ kind: 'get' });

TResponse = unknown

OmitReplyTo<TCommand>

number = DEFAULT_ASK_TIMEOUT_MS

Promise<TResponse>

ActorRef.ask


equals(other): boolean

Defined in: src/ActorRef.ts:104

ActorRef

boolean

ActorRef.equals


hasPending(): boolean

Defined in: src/cluster/singleton/ClusterSingletonProxy.ts:154

True if at least one message is currently buffered.

boolean


kill(): void

Defined in: src/ActorRef.ts:100

Kill this actor — raises ActorKilledError through the normal supervision path.

void

ActorRef.kill


send(message): void

Defined in: src/ActorRef.ts:64

Alias for tell — useful if you want to pipe something.

TCommand

void

ActorRef.send


stop(): void

Defined in: src/cluster/singleton/ClusterSingletonProxy.ts:117

A singleton is not stopped by poisoning its proxy — the proxy is a forwarder, not the actor. ActorRef.stop() means “send a PoisonPill to the target” everywhere else, and doing that here would kill whatever the current leader happens to be hosting. Overridden to say so instead.

void

ActorRef.stop


tell(message, _sender?): void

Defined in: src/cluster/singleton/ClusterSingletonProxy.ts:69

Send a message to this actor. sender is surfaced as context.sender in the recipient.

TCommand

ActorRef<unknown> | null

void

ActorRef.tell


toString(): string

Defined in: src/ActorRef.ts:102

string

ActorRef.toString