A11 TypeScript API - v0.7.0
    Preparing search index...

    Class ChunkStoreWriter

    Bounded, batched, stackless writer over a ChunkStore.

    Producers enqueue chunks in logical sequence order. Await admitted to respect queue backpressure and confirmation to know storage accepted the fragment. The writer also calls send on attached wire streams; that call confirms local transport admission, not delivery by the remote agent.

    A final write fixes the logical end of the sequence. Lifecycle methods then either drain and seal storage, propagate an error, or cancel immediately.

    Index
    options: Readonly<NormalizedWriterOptions>

    Validated immutable writer options.

    store: ChunkStore

    Ordered storage receiving committed fragments.

    • get queueSize(): number

      Number of admitted and backpressured chunks still awaiting completion.

      Returns number

    • Flush queued chunks and close the backing store to further writes.

      This does not append a final fragment. Mark the last write final (or call finalize) when readers need a final sequence number to identify the logical end of the stream.

      Returns Promise<Status>

    • Enqueue a chunk and expose admission and persistence as separate promises.

      Parameters

      • chunk: Chunk
      • seq: number | null = null
      • final: boolean = false
      • ensureStarted: boolean = true

      Returns ChunkStoreWrite

    • Write chunk as the final fragment and, unless told not to, close.

      The chunk is enqueued before closure is asked for, and that order is the whole of the synchronisation: the pump only starts its close once nothing is outstanding, and admits whatever the bounded buffer held back before that count reaches zero. So a close requested here cannot overtake the chunk. With wait false the returned promise resolves immediately and both are left to the pump; a failure is reported rather than dropped, and stays visible through getStatus. AsyncNode.finalize is the entry point application code wants -- it serializes values for you.

      Parameters

      • chunk: Chunk
      • seq: number | null = null
      • wait: boolean = false
      • close: boolean = true

      Returns Promise<Status>

    • Apply backpressure, persist a chunk, and return its confirmed sequence.

      Parameters

      • chunk: Chunk
      • seq: number | null = null
      • final: boolean = false

      Returns Promise<StatusOr<number>>