Skip to content

ShardingSettings

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

TMsg

readonly entityProps: Props<TMsg>

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


readonly extractEntityId: (message) => string

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

TMsg

string


readonly optional extractEntityMessage?: (message) => unknown

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

TMsg

unknown


readonly optional maxEntities?: number

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

Cap the number of locally-hosted entities (#82). When the region is about to spawn a new entity and the existing count is already maxEntities, the entity with the oldest lastActivity is passivated — same code path users invoke manually via Passivate. Useful for unbounded entity sets (per-user sessions, IoT devices, …) where a memory cap per node matters more than keeping every cold entity resident.

Default: 0 (no cap). Eviction runs only when > 0.

Note: passivation is asynchronous, so during the brief window between “stop the LRU” and “Terminated arrives” the region may hold maxEntities + 1 entities; the cap is a steady-state upper bound rather than a strict instantaneous one.


readonly optional numShards?: number

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


readonly optional passivationIdleMs?: number

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

Notify the region after an entity has been idle this many ms.


readonly optional proxy?: boolean

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

Run as a proxy — route messages but never host entities locally.


readonly optional rememberEntities?: boolean

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

Track entity lifecycle so entities can be re-created on the new owner.


readonly optional role?: string

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

Members must carry this role to be candidates for hosting shards.


readonly typeName: string

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