Skip to content

ShardRegion

Defined in: src/cluster/sharding/ShardRegion.ts:100

ShardRegion is the node-local router for a sharded type. It talks to the ShardCoordinator to discover the home of each shard, hosts entities whose shards live locally, and forwards everything else to the remote region that owns the target shard. Messages whose shard home is unknown or in handoff are buffered until the coordinator answers.

TMsg = unknown

new ShardRegion<TMsg>(cfg): ShardRegion<TMsg>

Defined in: src/cluster/sharding/ShardRegion.ts:128

ShardRegionConfig<TMsg>

ShardRegion<TMsg>

Actor.constructor

readonly cfg: ShardRegionConfig<TMsg>

Defined in: src/cluster/sharding/ShardRegion.ts:128

onReceive(message): void

Defined in: src/cluster/sharding/ShardRegion.ts:185

Main message handler. Receives each envelope dequeued from the mailbox. A thrown error (sync or async) is caught by the supervisor.

Terminated | Passivate | ShardingMessage | TMsg

void

Actor.onReceive


postRestart(_reason): void | Promise<void>

Defined in: src/Actor.ts:55

Called on the fresh instance after a restart. Default: call preStart().

Error

void | Promise<void>

Actor.postRestart


postStop(): void

Defined in: src/cluster/sharding/ShardRegion.ts:178

Called after the actor has been terminated. Children are already stopped.

void

Actor.postStop


preRestart(_reason, _message?): void | Promise<void>

Defined in: src/Actor.ts:50

Called before a restart, on the instance about to be thrown away. The default stops children and then calls postStop().

Error

Terminated | Passivate | ShardingMessage | TMsg

void | Promise<void>

Actor.preRestart


preStart(): void

Defined in: src/cluster/sharding/ShardRegion.ts:151

Called after construction and before the first message is processed.

void

Actor.preStart


supervisorStrategy(): SupervisorStrategy

Defined in: src/Actor.ts:63

Supervisor strategy for this actor’s children. Defaults to restart, up to 10 times per minute, then stop.

SupervisorStrategy

Actor.supervisorStrategy


static settingsToConfig<TMsg>(s, cluster, localResolver): ShardRegionConfig<TMsg>

Defined in: src/cluster/sharding/ShardRegion.ts:130

TMsg

ShardingSettings<TMsg>

Cluster

(path) => ActorRef<unknown> | null

ShardRegionConfig<TMsg>