Zum Inhalt springen
Deutsch

ClusterSharding

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

Defined in: src/cluster/sharding/ClusterSharding.ts:75

User-facing entry point. Attaches to an ActorSystem + Cluster pair and lets you start a sharded region for each entity type. A ShardCoordinator is spawned lazily on every node; only the one hosted by the current cluster leader is active — the rest act as warm standbys.

readonly cluster: Cluster

Defined in: src/cluster/sharding/ClusterSharding.ts:81


readonly system: ActorSystem

Defined in: src/cluster/sharding/ClusterSharding.ts:80

start<TMsg>(settings): ActorRef<TMsg>

Defined in: src/cluster/sharding/ClusterSharding.ts:118

Start a sharded region for a type. Three calling shapes:

// Shorthand: pass the entity class. Framework wraps it with Props.create.
sharding.start('counter', CounterEntity, {
extractEntityId: (msg) => msg.id,
});
// Shorthand: pass a factory. Useful for closures / DI / no-arg new.
sharding.start('cart', () => new CartEntity(deps), {
extractEntityId: (msg) => msg.entityId,
});
// Full-form: explicit Props + all settings (unchanged).
sharding.start({
typeName: 'counter',
entityProps: Props.create(() => new CounterEntity()),
extractEntityId: (msg) => msg.id,
});

TMsg

StartSettings<TMsg>

ActorRef<TMsg>

start<TMsg>(typeName, entity, opts): ActorRef<TMsg>

Defined in: src/cluster/sharding/ClusterSharding.ts:119

Start a sharded region for a type. Three calling shapes:

// Shorthand: pass the entity class. Framework wraps it with Props.create.
sharding.start('counter', CounterEntity, {
extractEntityId: (msg) => msg.id,
});
// Shorthand: pass a factory. Useful for closures / DI / no-arg new.
sharding.start('cart', () => new CartEntity(deps), {
extractEntityId: (msg) => msg.entityId,
});
// Full-form: explicit Props + all settings (unchanged).
sharding.start({
typeName: 'counter',
entityProps: Props.create(() => new CounterEntity()),
extractEntityId: (msg) => msg.id,
});

TMsg

string

(() => Actor<TMsg>) | (() => Actor<TMsg>)

Omit<StartSettings<TMsg>, "typeName" | "entityProps">

ActorRef<TMsg>


startProxy<TMsg>(settings): ActorRef<TMsg>

Defined in: src/cluster/sharding/ClusterSharding.ts:174

Start a proxy region — routes to the cluster but never hosts entities.

TMsg

Omit<StartSettings<TMsg>, "proxy">

ActorRef<TMsg>


static get(system, cluster): ClusterSharding

Defined in: src/cluster/sharding/ClusterSharding.ts:88

ActorSystem

Cluster

ClusterSharding