コンテンツにスキップ
日本語

OptionsBuilder

このコンテンツはまだ日本語訳がありません。

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

Base class for the framework’s fluent options builders — the shared mechanics behind MqttOptions, KafkaOptions, ActorSystemOptions, and every other <X>Options builder.

Design (matches the hand-written MqttOptions that seeded this):

  • Mutable, this-returning. Each concrete withX(...) calls the protected set and returns this, so chaining stays typed as the concrete subclass across inheritance levels (no F-bounded Self generic needed — this already IS the subclass).
  • A builder is its options. set writes each field as an own enumerable property of the builder instance, so a builder is structurally a bag of the fields you set. Consumers accept the XOptions union (XOptionsBuilder | Partial<XOptionsType>) and read / spread the argument directly — no separate “resolve” step. The withX / build methods live on the prototype, so they never surface when the options are spread ({ ...options }), enumerated (Object.keys), or serialized (JSON.stringify): only the set fields do. (The consumer keeps the union in its signature because a builder — a methods-only type — is not assignable to a bare Partial<T>: TypeScript’s weak-type check would reject it. Reading the options out of the argument is a plain cast: options as XOptionsType / { ...(options as Partial<XOptionsType>) }.)
  • build() snapshots. It returns an independent Partial<T> (a copy of the own fields) for the rare caller that wants to freeze a builder it intends to keep mutating; ordinary consumers don’t need it because they already read/spread the argument.
  • Feeds the existing resolution. Wherever HOCON is layered in — the broker actors, ClusterSharding.start — the options are the highest-precedence layer of mergeOptions(defaults, HOCON, explicit); because a builder records ONLY the fields you set, unset fields fall through to HOCON — the builder never competes with config.

A builder instance is a throwaway construction helper: methods mutate in place, so a single instance is not a branch point (two chains off the same instance share state).

T extends object

new OptionsBuilder<T>(): OptionsBuilder<T>

OptionsBuilder<T>

build(): Partial<T>

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

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

Partial<T>