Setu-TS
    Preparing search index...

    Class RedisQueue

    Redis queue adapter implementation.

    Uses Redis sorted sets (ZSET) for ready/processing/dead sets and hashes (HASH) for job payloads. Implements the claim-based reserve pattern to prevent double-dispatch.

    Key structure per job name:

    • queue:<name>:ready - ZSET (score = availableAtMs, member = jobId)
    • queue:<name>:processing - ZSET (score = lease deadline on the Redis clock)
    • queue:<name>:claims / stalls - HASH (delivery tokens / abandoned attempts)
    • queue:<name>:claimseq - persistent INCR sequence shared across replicas
    • queue:<name>:dead - ZSET (score = deadLetterAtMs, member = jobId)
    • queue:<name>:jobs - HASH (field = jobId, value = JSON job)
    • queue:<name>:dead:jobs - HASH (dead payloads; only when a TTL is configured)

    Recurring jobs:

    • queue:recurring:due - ZSET (score = nextRunAtMs, member = recurringId)
    • queue:recurring:jobs - HASH (field = recurringId, value = JSON recurring)

    0.1.0

    Implements

    • QueueAdapter
    Index
    claimRenewal?: {
        intervalMs: number;
        extend(name: string, id: string, claimToken: string): Promise<boolean>;
    }

    Renewed lease, present only while connected to an eval-capable client.

    depths?: (name: string) => Promise<QueueDepths>

    M70k (X8-4): counts this name's three states with one ZCARD each.

    Absent on a client that does not expose zcard, which is why the member is an assigned property rather than a declared method — the health indicator must be able to tell "cannot report" from "nothing there". Absent again after disconnect, for the same reason isHealthy is: the closure captures the client it was installed for, so leaving it in place would answer a depth read with that dead client's rejection instead of the absence that says the adapter cannot count right now.

    Type Declaration

      • (name: string): Promise<QueueDepths>
      • Parameters

        • name: string

          Job name

        Returns Promise<QueueDepths>

        The depth of each state

    0.3.0

    isHealthy?: () => Promise<boolean>

    M70c: present only when the client exposes ping(); its absence is unknown reachability, not false (a minimal injected fake has not told us the server is dead).

    0.1.0

    • Acknowledges a job as successfully processed.

      Parameters

      • name: string

        Job name

      • id: string

        Job ID (stable public identity)

      • OptionalclaimToken: string

        Opaque claim token returned from reserve (prevents stale settlement)

      Returns Promise<void>

      Resolves when acknowledged

      If the adapter is not connected

      0.1.0

    • Advances a recurring job's next run time.

      Parameters

      • id: string

        Recurring job ID

      • nextRunAtMs: number

        Next run timestamp

      Returns Promise<void>

      Resolves when advanced

      If the adapter is not connected

      0.1.0

    • Moves a job to the dead letter queue.

      Parameters

      • name: string

        Job name

      • id: string

        Job ID (stable public identity)

      • nowMs: number

        Current timestamp in ms (for dead-letter timestamp)

      • OptionalclaimToken: string

        Opaque claim token returned from reserve (prevents stale settlement)

      Returns Promise<void>

      Resolves when dead-lettered

      If the adapter is not connected

      0.1.0

    • Enqueues a job.

      Type Parameters

      • T

      Parameters

      • job: StoredJob<T>

        The job to enqueue

      Returns Promise<void>

      Resolves when enqueued

      If the adapter is not connected

      0.1.0

    • Fetches recurring jobs that are due.

      Parameters

      • nowMs: number

        Current timestamp in ms

      Returns Promise<readonly StoredRecurring[]>

      The due recurring jobs

      If the adapter is not connected

      0.1.0

    • Requeues a job with a new available timestamp.

      Type Parameters

      • T

      Parameters

      • name: string

        Job name

      • id: string

        Job ID (stable public identity)

      • availableAtMs: number

        When the job becomes available again

      • attempts: number

        Updated attempt count

      • OptionalclaimToken: string

        Opaque claim token returned from reserve (prevents stale settlement)

      Returns Promise<void>

      Resolves when requeued

      If the adapter is not connected

      0.1.0

    • Reserves up to limit due jobs. Redis scripts use server time; adapters without a server clock compare availableAtMs to nowMs.

      CLAIMS jobs: moves them from ready set to processing set. A reserved job is not returned by subsequent reserve calls.

      Type Parameters

      • T

      Parameters

      • name: string

        Job name

      • limit: number

        Maximum jobs to reserve

      • nowMs: number

        Caller timestamp in ms, used when there is no server clock

      Returns Promise<readonly StoredJob<T>[]>

      The reserved jobs

      If the adapter is not connected

      0.1.0

    • Stores a recurring job.

      Parameters

      • rec: StoredRecurring

        The recurring job to store

      Returns Promise<void>

      Resolves when stored

      If the adapter is not connected

      0.1.0