@chip/cstd - v0.0.8
    Preparing search index...

    Interface Queue<T, K>

    interface Queue<T, K> {
        checkedOut: () => Record<string, number>;
        complete: (job: CompletedJob<T, K>, worker: string) => void;
        completedCount: () => number;
        pop: (worker: string) => Job<T> | undefined;
        push: (job: Omit<Job<T>, "id"> & Partial<Pick<Job<T>, "id">>) => void;
        requeue: (worker: string) => void;
        requeueAll: () => void;
        scores: () => Record<string, number>;
        toDoCount: () => number;
    }

    Type Parameters

    • T
    • K
    Index

    Properties

    checkedOut: () => Record<string, number>

    Get the number of jobs checked out to each worker.

    complete: (job: CompletedJob<T, K>, worker: string) => void

    Mark a job as completed.

    Type Declaration

      • (job: CompletedJob<T, K>, worker: string): void
      • Parameters

        • job: CompletedJob<T, K>

          Completed job item, including the result and success status.

        • worker: string

          Worker name/identifier to credit.

        Returns void

    completedCount: () => number
    pop: (worker: string) => Job<T> | undefined

    Pop a job off the queue for the given worker.

    Type Declaration

      • (worker: string): Job<T> | undefined
      • Parameters

        • worker: string

          The worker name/identifier.

        Returns Job<T> | undefined

        Job or undefined if no job is available.

    push: (job: Omit<Job<T>, "id"> & Partial<Pick<Job<T>, "id">>) => void

    Push a job onto the queue.

    requeue: (worker: string) => void

    Requeue all jobs for a given worker.

    requeueAll: () => void

    Requeue all jobs for all workers.

    scores: () => Record<string, number>

    Get the scores for all workers.

    Type Declaration

      • (): Record<string, number>
      • Returns Record<string, number>

        A record of worker names and their respective scores.

    toDoCount: () => number