ClusterSharding
Ce contenu n’est pas encore disponible dans votre langue.
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.
Properties
Section titled “Properties”cluster
Section titled “cluster”
readonlycluster:Cluster
Defined in: src/cluster/sharding/ClusterSharding.ts:81
system
Section titled “system”
readonlysystem:ActorSystem
Defined in: src/cluster/sharding/ClusterSharding.ts:80
Methods
Section titled “Methods”start()
Section titled “start()”Call Signature
Section titled “Call Signature”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,});Type Parameters
Section titled “Type Parameters”TMsg
Parameters
Section titled “Parameters”settings
Section titled “settings”StartSettings<TMsg>
Returns
Section titled “Returns”ActorRef<TMsg>
Call Signature
Section titled “Call Signature”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,});Type Parameters
Section titled “Type Parameters”TMsg
Parameters
Section titled “Parameters”typeName
Section titled “typeName”string
entity
Section titled “entity”(() => Actor<TMsg>) | (() => Actor<TMsg>)
Omit<StartSettings<TMsg>, "typeName" | "entityProps">
Returns
Section titled “Returns”ActorRef<TMsg>
startProxy()
Section titled “startProxy()”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.
Type Parameters
Section titled “Type Parameters”TMsg
Parameters
Section titled “Parameters”settings
Section titled “settings”Omit<StartSettings<TMsg>, "proxy">
Returns
Section titled “Returns”ActorRef<TMsg>
staticget(system,cluster):ClusterSharding
Defined in: src/cluster/sharding/ClusterSharding.ts:88
Parameters
Section titled “Parameters”system
Section titled “system”cluster
Section titled “cluster”Returns
Section titled “Returns”ClusterSharding