跳转到内容
简体中文

StartShardingOptionsBuilder

此内容尚不支持你的语言。

Defined in: src/cluster/sharding/StartShardingOptions.ts:73

Fluent builder for StartShardingOptionsType — the argument to ClusterSharding.start. Extends ShardingOptionsBuilder so it carries every region-side withX (typeName, entityActor, extractors, numShards, role, proxy, rememberEntities, …) and adds the coordinator-side fields on top.

The polymorphic fields are passed whole via a single withX(value): allocationStrategy (AllocationStrategy), lease (Lease), rememberEntitiesStore, and coordinatorStateStore.

TMessage

new StartShardingOptionsBuilder<TMessage>(): StartShardingOptionsBuilder<TMessage>

StartShardingOptionsBuilder<TMessage>

ShardingOptionsBuilder.constructor

build(): Partial<T>

Defined in: src/util/OptionsBuilder.ts:51

Snapshot the set fields as an independent Partial<T> (own props only).

Partial<T>

ShardingOptionsBuilder.build


withAcquireRetryIntervalMs(acquireRetryIntervalMs): this

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

Retry interval for lease.acquire() after a failed attempt. Default: 5 s.

number

this


withAllocationStrategy(allocationStrategy): this

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

Strategy the coordinator uses to allocate and rebalance shards.

AllocationStrategy

this


withCoordinatorStateStore(coordinatorStateStore): this

Defined in: src/cluster/sharding/StartShardingOptions.ts:113

Persistence backend for the coordinator’s allocation state.

CoordinatorStateStore

this


withEntityActor(entityActor): this

Defined in: src/cluster/sharding/ShardingOptions.ts:133

The actor each entity instance is built from.

ActorClassOrFactory<TMessage>

this

ShardingOptionsBuilder.withEntityActor


withEntityOptions(entityOptions): this

Defined in: src/cluster/sharding/ShardingOptions.ts:138

Spawn options applied to every entity of this type.

ActorOptions<TMessage>

this

ShardingOptionsBuilder.withEntityOptions


withExtractEntityId(extractEntityId): this

Defined in: src/cluster/sharding/ShardingOptions.ts:143

Derive the stable entity id from an incoming message.

(message) => string

this

ShardingOptionsBuilder.withExtractEntityId


withExtractEntityMessage(extractEntityMessage): this

Defined in: src/cluster/sharding/ShardingOptions.ts:148

Unwrap the payload actually delivered to the entity. Default: identity.

(message) => unknown

this

ShardingOptionsBuilder.withExtractEntityMessage


withHandOffTimeoutMs(handOffTimeoutMs): this

Defined in: src/cluster/sharding/StartShardingOptions.ts:90

Time to wait for HandOffComplete before force-reallocating.

number

this


withLease(lease): this

Defined in: src/cluster/sharding/StartShardingOptions.ts:95

Optional split-brain protection for the coordinator (a Lease).

Lease

this


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).

number

this

ShardingOptionsBuilder.withMaxEntities


withNumShards(numShards): this

Defined in: src/cluster/sharding/ShardingOptions.ts:153

Number of shards to spread entities across. Default: 64.

number

this

ShardingOptionsBuilder.withNumShards


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.

number

this

ShardingOptionsBuilder.withPassivationIdleMs


withProxy(proxy?): this

Defined in: src/cluster/sharding/ShardingOptions.ts:163

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

boolean = true

this

ShardingOptionsBuilder.withProxy


withRebalanceIntervalMs(rebalanceIntervalMs): this

Defined in: src/cluster/sharding/StartShardingOptions.ts:85

Gap between coordinator-driven rebalance passes.

number

this


withRememberEntities(rememberEntities?): this

Defined in: src/cluster/sharding/ShardingOptions.ts:168

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

boolean = true

this

ShardingOptionsBuilder.withRememberEntities


withRememberEntitiesStore(rememberEntitiesStore): this

Defined in: src/cluster/sharding/StartShardingOptions.ts:108

Persistence backend for the entity registry (only when rememberEntities). Pass null to keep the registry in-memory only (opt out of persistence).

RememberEntitiesStore | null

this


withRole(role): this

Defined in: src/cluster/sharding/ShardingOptions.ts:158

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

string

this

ShardingOptionsBuilder.withRole


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.

number

this

ShardingOptionsBuilder.withShardPassivationIdleMs


withTypeName(typeName): this

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

Logical name of the sharded type.

string

this

ShardingOptionsBuilder.withTypeName


static create<TMessage>(): StartShardingOptionsBuilder<TMessage>

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

Start a fresh builder. Equivalent to new StartShardingOptionsBuilder<TMessage>().

TMessage

StartShardingOptionsBuilder<TMessage>

ShardingOptionsBuilder.create