-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.ts
29 lines (25 loc) · 1.03 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import type { Redis } from "./deps.ts";
// https://github.com/sindresorhus/type-fest
type JsonObject =
& { [Key in string]: JsonValue }
& { [Key in string]?: JsonValue | undefined };
type JsonArray = JsonValue[] | readonly JsonValue[];
type JsonPrimitive = string | number | boolean | null;
type JsonValue = JsonPrimitive | JsonObject | JsonArray;
export type MultiQueue<Queue extends JsonValue, Job extends JsonValue> = {
push: (queue: Queue, job: Job, priority: number) => Promise<void>;
pop: (queue: Queue) => Promise<Job | undefined>;
complete: (queue: Queue, job: Job) => Promise<void>;
getDeepest: () => Promise<Queue | undefined>;
popAny: (queues?: Queue[]) => Promise<Job | undefined>;
getQueueDepths: () => Promise<Map<Queue, number>>;
getRetryDepths: () => Promise<Map<Queue, number>>;
};
export type CreateMultiQueueOptions = {
redis: Redis;
prefix: string;
retryAfter: number;
};
export type CreateMultiQueue = <Queue extends JsonValue, Job extends JsonValue>(
options: CreateMultiQueueOptions,
) => MultiQueue<Queue, Job>;