Interface IPersistIntervalInstance

Per-bucket interval marker persistence instance interface. Used by Interval.file for once-per-interval signal firing.

A record's presence means the interval has already fired for that bucket+key. Soft-deleted records (removed=true) act as if absent, allowing the function to fire again.

Custom adapters should implement this interface to override the default file-based interval marker behavior.

interface IPersistIntervalInstance {
    listIntervalData(): AsyncGenerator<string>;
    readIntervalData(key: string): Promise<IntervalData>;
    removeIntervalData(key: string): Promise<void>;
    waitForInit(initial: boolean): Promise<void>;
    writeIntervalData(
        data: IntervalData,
        key: string,
        when: Date,
    ): Promise<void>;
}

Implemented by

Methods

  • Iterate all non-removed marker keys for this bucket.

    Returns AsyncGenerator<string>

    AsyncGenerator yielding marker keys

  • Read interval marker by key.

    Parameters

    • key: string

      Marker key within the bucket

    Returns Promise<IntervalData>

    Promise resolving to stored value, or null if not found or soft-deleted

  • Soft-delete a marker. After this call the function will fire again on the next IntervalFileInstance.run call for the same key.

    Parameters

    • key: string

      Marker key within the bucket

    Returns Promise<void>

    Promise that resolves when removal is complete

  • Initialize storage for this bucket.

    Parameters

    • initial: boolean

      Whether this is the first initialization

    Returns Promise<void>

    Promise that resolves when initialization is complete

  • Write interval marker.

    Parameters

    • data: IntervalData

      Data to store

    • key: string

      Marker key within the bucket

    • when: Date

    Returns Promise<void>

    Promise that resolves when write is complete