ShardingOptionsBuilder
此内容尚不支持你的语言。
Defined in: src/cluster/sharding/ShardingOptions.ts:118
Fluent builder for ShardingOptionsType. Base of the builder
inheritance chain: StartShardingOptionsBuilder (in
StartShardingOptions) extends this and adds the coordinator-side
fields. Each concrete withX records exactly one field so unset
fields fall through to HOCON / built-in defaults when the options are
normalised by ShardRegion.settingsToConfig.
The whole-object fields — entityActor, entityOptions, and the
extractEntityId / extractEntityMessage extractors — are passed
as-is via a single withX(value); no nested builders.
Extends
Section titled “Extends”Extended by
Section titled “Extended by”Type Parameters
Section titled “Type Parameters”TMessage
Section titled “TMessage”TMessage
S extends ShardingOptionsType<TMessage> = ShardingOptionsType<TMessage>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new ShardingOptionsBuilder<
TMessage,S>():ShardingOptionsBuilder<TMessage,S>
Returns
Section titled “Returns”ShardingOptionsBuilder<TMessage, S>
Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”build()
Section titled “build()”build():
Partial<T>
Defined in: src/util/OptionsBuilder.ts:51
Snapshot the set fields as an independent Partial<T> (own props only).
Returns
Section titled “Returns”Partial<T>
Inherited from
Section titled “Inherited from”withEntityActor()
Section titled “withEntityActor()”withEntityActor(
entityActor):this
Defined in: src/cluster/sharding/ShardingOptions.ts:133
The actor each entity instance is built from.
Parameters
Section titled “Parameters”entityActor
Section titled “entityActor”ActorClassOrFactory<TMessage>
Returns
Section titled “Returns”this
withEntityOptions()
Section titled “withEntityOptions()”withEntityOptions(
entityOptions):this
Defined in: src/cluster/sharding/ShardingOptions.ts:138
Spawn options applied to every entity of this type.
Parameters
Section titled “Parameters”entityOptions
Section titled “entityOptions”ActorOptions<TMessage>
Returns
Section titled “Returns”this
withExtractEntityId()
Section titled “withExtractEntityId()”withExtractEntityId(
extractEntityId):this
Defined in: src/cluster/sharding/ShardingOptions.ts:143
Derive the stable entity id from an incoming message.
Parameters
Section titled “Parameters”extractEntityId
Section titled “extractEntityId”(message) => string
Returns
Section titled “Returns”this
withExtractEntityMessage()
Section titled “withExtractEntityMessage()”withExtractEntityMessage(
extractEntityMessage):this
Defined in: src/cluster/sharding/ShardingOptions.ts:148
Unwrap the payload actually delivered to the entity. Default: identity.
Parameters
Section titled “Parameters”extractEntityMessage
Section titled “extractEntityMessage”(message) => unknown
Returns
Section titled “Returns”this
withMaxEntities()
Section titled “withMaxEntities()”withMaxEntities(
maxEntities):this
Defined in: src/cluster/sharding/ShardingOptions.ts:183
Cap the number of locally-hosted entities; LRU-passivate on overflow. Default: 0 (no cap).
Parameters
Section titled “Parameters”maxEntities
Section titled “maxEntities”number
Returns
Section titled “Returns”this
withNumShards()
Section titled “withNumShards()”withNumShards(
numShards):this
Defined in: src/cluster/sharding/ShardingOptions.ts:153
Number of shards to spread entities across. Default: 64.
Parameters
Section titled “Parameters”numShards
Section titled “numShards”number
Returns
Section titled “Returns”this
withPassivationIdleMs()
Section titled “withPassivationIdleMs()”withPassivationIdleMs(
passivationIdleMs):this
Defined in: src/cluster/sharding/ShardingOptions.ts:173
Passivate an entity after it has been idle this many ms. Default: 5 min; 0 disables.
Parameters
Section titled “Parameters”passivationIdleMs
Section titled “passivationIdleMs”number
Returns
Section titled “Returns”this
withProxy()
Section titled “withProxy()”withProxy(
proxy?):this
Defined in: src/cluster/sharding/ShardingOptions.ts:163
Run as a proxy — route messages but never host entities locally.
Parameters
Section titled “Parameters”proxy?
Section titled “proxy?”boolean = true
Returns
Section titled “Returns”this
withRememberEntities()
Section titled “withRememberEntities()”withRememberEntities(
rememberEntities?):this
Defined in: src/cluster/sharding/ShardingOptions.ts:168
Track entity lifecycle so entities can be re-created on the new owner.
Parameters
Section titled “Parameters”rememberEntities?
Section titled “rememberEntities?”boolean = true
Returns
Section titled “Returns”this
withRole()
Section titled “withRole()”withRole(
role):this
Defined in: src/cluster/sharding/ShardingOptions.ts:158
Members must carry this role to be candidates for hosting shards.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”this
withShardPassivationIdleMs()
Section titled “withShardPassivationIdleMs()”withShardPassivationIdleMs(
shardPassivationIdleMs):this
Defined in: src/cluster/sharding/ShardingOptions.ts:178
Stop a shard once it has stood empty this many ms. Default: follows passivationIdleMs.
Parameters
Section titled “Parameters”shardPassivationIdleMs
Section titled “shardPassivationIdleMs”number
Returns
Section titled “Returns”this
withTypeName()
Section titled “withTypeName()”withTypeName(
typeName):this
Defined in: src/cluster/sharding/ShardingOptions.ts:128
Logical name of the sharded type.
Parameters
Section titled “Parameters”typeName
Section titled “typeName”string
Returns
Section titled “Returns”this
create()
Section titled “create()”
staticcreate<TMessage>():ShardingOptionsBuilder<TMessage>
Defined in: src/cluster/sharding/ShardingOptions.ts:123
Start a fresh builder. Equivalent to new ShardingOptionsBuilder<TMessage>().
Type Parameters
Section titled “Type Parameters”TMessage
Section titled “TMessage”TMessage
Returns
Section titled “Returns”ShardingOptionsBuilder<TMessage>
