pamoja for TypeScript - v0.2.0
    Preparing search index...

    Class Store

    A store-and-forward buffer.

    Handing a store to a ladder consumes it, because the ladder owns it from then on. A consumed store is emptied rather than left aliasing what now belongs to the ladder, so using one twice throws.

    Index
    • get isAvailable(): boolean

      Whether this store is still holdable, or has been given to a ladder.

      Returns boolean

    • Adds a record to the end of the buffer: bytes, or text such as a reading written out.

      Parameters

      • record: string | Buffer<ArrayBufferLike>

      Returns Promise<void>

    • Drains the buffer onto a transport, publishing each record to topic, oldest first, and resolves with how many went out.

      Each record leaves the buffer only once the transport has taken it, so a send that fails rejects with the transport's error and leaves that record and every one after it buffered, in order, for the next drain. The transport is driven, not consumed.

      Parameters

      Returns Promise<number>

    • Reads the oldest record without removing it, or null when empty.

      Returns Promise<Buffer<ArrayBufferLike> | null>

    • Reads the oldest record as text without removing it, or null when empty.

      Throws if the record is not UTF-8 text.

      Returns Promise<string | null>

    • Removes and returns the oldest record, or null when empty.

      Returns Promise<Buffer<ArrayBufferLike> | null>

    • Removes and returns the oldest record as text, or null when empty.

      Throws if the record is not UTF-8 text.

      Returns Promise<string | null>

    • Opens a buffer backed by a directory, so it survives a restart.

      A record a power cut interrupted mid-write is never seen, and one written before the cut is found again when the directory is reopened.

      Parameters

      • dir: string

        the directory to hold records in; it is created if missing.

      • Optionalcapacity: number | null

        the most records to hold, or omitted for no bound. A full store refuses the next append, which keeps a long outage from filling the disk.

      Returns sync.Store

    • Creates a buffer held in memory.

      Parameters

      • Optionalcapacity: number | null

        the most records to hold, or omitted for no bound. A full store refuses the next append rather than dropping anything, so a record is never lost without the caller being told.

      Returns sync.Store