@pingpolls/redisq 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/app.d.ts ADDED
@@ -0,0 +1,92 @@
1
+ import { RedisClient as BunRedisClient } from "bun";
2
+ export type QueueOptions = {
3
+ redis: BunRedisClient;
4
+ } | {
5
+ host: string;
6
+ port: string;
7
+ user?: string;
8
+ password?: string;
9
+ namespace?: string;
10
+ tls?: boolean;
11
+ };
12
+ export type CreateQueueOptions<QueueName extends string = string> = QueueName extends `${string}:batch` ? {
13
+ qname: QueueName;
14
+ maxsize?: number;
15
+ maxRetries?: number;
16
+ maxBackoffSeconds?: number;
17
+ every?: number;
18
+ } : {
19
+ qname: QueueName;
20
+ maxsize?: number;
21
+ maxRetries?: number;
22
+ maxBackoffSeconds?: number;
23
+ };
24
+ export interface QueueAttributes {
25
+ maxsize: number;
26
+ created: number;
27
+ msgs: number;
28
+ isBatch: boolean;
29
+ maxRetries: number;
30
+ maxBackoffSeconds: number;
31
+ every?: number;
32
+ }
33
+ export interface SendMessageOptions {
34
+ qname: string;
35
+ message: string;
36
+ delay?: number;
37
+ }
38
+ export interface SendBatchMessageOptions {
39
+ qname: string;
40
+ batchId: string;
41
+ message: string;
42
+ }
43
+ export interface Message {
44
+ id: string;
45
+ message: string;
46
+ sent: number;
47
+ attempt: number;
48
+ }
49
+ export interface BatchMessage {
50
+ batchId: string;
51
+ messages: Omit<Message, "attempt">[];
52
+ sent: number;
53
+ attempt: number;
54
+ }
55
+ export declare class RedisQ {
56
+ private redis;
57
+ private redisUrl;
58
+ private ns;
59
+ private workers;
60
+ private batchJobs;
61
+ private isClosing;
62
+ constructor(options: QueueOptions);
63
+ private getKey;
64
+ private isBatchQueue;
65
+ createQueue<QueueName extends string>(options: CreateQueueOptions<QueueName>): Promise<boolean>;
66
+ listQueues(): Promise<string[]>;
67
+ getQueue(qname: string): Promise<QueueAttributes | null>;
68
+ deleteQueue(qname: string): Promise<boolean>;
69
+ sendMessage(options: SendMessageOptions): Promise<string>;
70
+ sendBatchMessage(options: SendBatchMessageOptions): Promise<string>;
71
+ private encodeMessage;
72
+ private decodeMessage;
73
+ private encodeBatchMeta;
74
+ private decodeBatchMeta;
75
+ private fetchMessages;
76
+ private fetchBatchMessage;
77
+ deleteMessage(qname: string, id: string): Promise<boolean>;
78
+ private deleteBatch;
79
+ private retryMessage;
80
+ private retryBatch;
81
+ private processDelayedMessages;
82
+ private processBatches;
83
+ startWorker<QueueName extends `${string}:batch` | (string & {})>(qname: QueueName, handler: (received: QueueName extends `${string}:batch` ? BatchMessage : Message) => Promise<{
84
+ success: boolean;
85
+ }>, options?: {
86
+ concurrency?: number;
87
+ silent?: boolean;
88
+ }): Promise<void>;
89
+ private runWorker;
90
+ stopWorker(qname: string): void;
91
+ close(): Promise<void>;
92
+ }