power-queues 2.0.21 → 2.1.0

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/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { JsonPrimitiveOrUndefined, PowerRedis, IORedisLike } from 'power-redis';
1
+ import { PowerRedis, IORedisLike } from 'power-redis';
2
2
 
3
3
  type SavedScript = {
4
4
  codeReady?: string;
@@ -12,10 +12,11 @@ type AddTasksOptions = {
12
12
  approx?: boolean;
13
13
  exact?: boolean;
14
14
  trimLimit?: number;
15
- id?: string;
15
+ job?: string;
16
16
  status?: boolean;
17
17
  statusTimeoutMs?: number;
18
- idem?: boolean;
18
+ attempt?: number;
19
+ createdAt?: number;
19
20
  };
20
21
  type Task = {
21
22
  job: string;
@@ -23,83 +24,70 @@ type Task = {
23
24
  createdAt?: number;
24
25
  payload: any;
25
26
  idemKey?: string;
26
- } | {
27
- job: string;
28
- id?: string;
29
- createdAt?: number;
30
- flat: JsonPrimitiveOrUndefined[];
31
- idemKey?: string;
27
+ attempt: number;
32
28
  };
33
29
 
34
30
  declare class PowerQueues extends PowerRedis {
35
31
  abort: AbortController;
36
32
  redis: IORedisLike;
37
33
  readonly scripts: Record<string, SavedScript>;
38
- readonly addingBatchTasksCount: number;
39
- readonly addingBatchKeysLimit: number;
40
- readonly workerExecuteLockTimeoutMs: number;
41
- readonly workerCacheTaskTimeoutMs: number;
42
- readonly approveBatchTasksCount: number;
43
- readonly removeOnExecuted: boolean;
44
- readonly executeBatchAtOnce: boolean;
45
- readonly executeJobStatus: boolean;
46
- readonly executeJobStatusTtlMs: number;
47
- readonly consumerHost: string;
48
- readonly stream: string;
34
+ readonly host: string;
49
35
  readonly group: string;
50
- readonly workerBatchTasksCount: number;
51
- readonly recoveryStuckTasksTimeoutMs: number;
52
- readonly workerLoopIntervalMs: number;
53
- readonly workerSelectionTimeoutMs: number;
54
- readonly workerMaxRetries: number;
55
- readonly workerClearAttemptsTimeoutMs: number;
56
- onSelected(data: Array<[string, any[], number, string, string]>): Promise<[string, any[], number, string, string][]>;
57
- onExecute(id: string, payload: any, createdAt: number, job: string, key: string, attempt: number): Promise<void>;
58
- onReady(data: Array<[string, any[], number, string, string]>): Promise<void>;
59
- onSuccess(id: string, payload: any, createdAt: number, job: string, key: string): Promise<void>;
60
- onBatchError(err: any, tasks?: Array<[string, any[], number, string, string]>): Promise<void>;
61
- onError(err: any, id: string, payload: any, createdAt: number, job: string, key: string): Promise<void>;
62
- onRetry(err: any, id: string, payload: any, createdAt: number, job: string, key: string, attempts: number): Promise<void>;
63
- runQueue(): Promise<void>;
64
- consumerLoop(): Promise<void>;
65
- addTasks(queueName: string, data: any[], opts?: AddTasksOptions): Promise<string[]>;
66
- loadScripts(full?: boolean): Promise<void>;
67
- private loadScript;
68
- private saveScript;
69
- private runScript;
70
- private xaddBatch;
71
- private payloadBatch;
72
- private buildBatches;
73
- private keysLength;
74
- private attemptsKey;
75
- private incrAttempts;
76
- private getAttempts;
77
- private clearAttempts;
78
- private success;
36
+ readonly selectStuckCount: number;
37
+ readonly selectStuckTimeout: number;
38
+ readonly selectStuckMaxTimeout: number;
39
+ readonly selectCount: number;
40
+ readonly selectTimeout: number;
41
+ readonly buildBatchCount: number;
42
+ readonly buildBatchMaxCount: number;
43
+ readonly retryCount: number;
44
+ readonly executeSync: boolean;
45
+ readonly idemLockTimeout: number;
46
+ readonly idemDoneTimeout: number;
47
+ readonly logStatus: boolean;
48
+ readonly logStatusTimeout: number;
49
+ readonly approveCount: number;
50
+ readonly removeOnExecuted: boolean;
51
+ private signal;
52
+ private consumer;
53
+ runQueue(queueName: string, from?: '$' | '0-0'): Promise<void>;
54
+ createGroup(queueName: string, from?: '$' | '0-0'): Promise<void>;
55
+ consumerLoop(queueName: string, from?: '$' | '0-0'): Promise<void>;
79
56
  private batchError;
80
- private error;
81
- private attempt;
57
+ private approve;
58
+ select(queueName: string, from?: '$' | '0-0'): Promise<any[]>;
59
+ private selectS;
60
+ private selectF;
61
+ private selectP;
62
+ private values;
63
+ private payload;
82
64
  private execute;
83
65
  private executeProcess;
84
- private approve;
85
- private idempotency;
86
66
  private idempotencyKeys;
87
67
  private idempotencyAllow;
88
68
  private idempotencyStart;
89
69
  private idempotencyDone;
90
70
  private idempotencyFree;
91
- private createGroup;
92
- private select;
93
- private selectStuck;
94
- private selectFresh;
71
+ private success;
72
+ private error;
95
73
  private waitAbortable;
96
74
  private sendHeartbeat;
97
75
  private heartbeat;
98
- private normalizeEntries;
99
- private values;
100
- private payload;
101
- private signal;
102
- private consumer;
76
+ private runScript;
77
+ loadScripts(full?: boolean): Promise<void>;
78
+ private loadScript;
79
+ private saveScript;
80
+ addTasks(queueName: string, data: any[], opts?: AddTasksOptions): Promise<string[]>;
81
+ private buildBatches;
82
+ private keysLength;
83
+ private payloadBatch;
84
+ beforeExecute(queueName: string, tasks: Array<[string, any[], number, string, string, number]>): Promise<[string, any[], number, string, string, number][]>;
85
+ onExecute(queueName: string, task: Task): Promise<void>;
86
+ onBatchSuccess(queueName: string, tasks: Array<[string, any[], number, string, string, number]>): Promise<void>;
87
+ onSuccess(queueName: string, task: Task): Promise<void>;
88
+ onError(err: any, queueName: string, task: Task): Promise<void>;
89
+ onBatchError(err: any, queueName: string, tasks: Array<[string, any[], number, string, string, number]>): Promise<void>;
90
+ onRetry(err: any, queueName: string, task: Task): Promise<void>;
103
91
  }
104
92
 
105
93
  export { type AddTasksOptions, PowerQueues, type Task };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { JsonPrimitiveOrUndefined, PowerRedis, IORedisLike } from 'power-redis';
1
+ import { PowerRedis, IORedisLike } from 'power-redis';
2
2
 
3
3
  type SavedScript = {
4
4
  codeReady?: string;
@@ -12,10 +12,11 @@ type AddTasksOptions = {
12
12
  approx?: boolean;
13
13
  exact?: boolean;
14
14
  trimLimit?: number;
15
- id?: string;
15
+ job?: string;
16
16
  status?: boolean;
17
17
  statusTimeoutMs?: number;
18
- idem?: boolean;
18
+ attempt?: number;
19
+ createdAt?: number;
19
20
  };
20
21
  type Task = {
21
22
  job: string;
@@ -23,83 +24,70 @@ type Task = {
23
24
  createdAt?: number;
24
25
  payload: any;
25
26
  idemKey?: string;
26
- } | {
27
- job: string;
28
- id?: string;
29
- createdAt?: number;
30
- flat: JsonPrimitiveOrUndefined[];
31
- idemKey?: string;
27
+ attempt: number;
32
28
  };
33
29
 
34
30
  declare class PowerQueues extends PowerRedis {
35
31
  abort: AbortController;
36
32
  redis: IORedisLike;
37
33
  readonly scripts: Record<string, SavedScript>;
38
- readonly addingBatchTasksCount: number;
39
- readonly addingBatchKeysLimit: number;
40
- readonly workerExecuteLockTimeoutMs: number;
41
- readonly workerCacheTaskTimeoutMs: number;
42
- readonly approveBatchTasksCount: number;
43
- readonly removeOnExecuted: boolean;
44
- readonly executeBatchAtOnce: boolean;
45
- readonly executeJobStatus: boolean;
46
- readonly executeJobStatusTtlMs: number;
47
- readonly consumerHost: string;
48
- readonly stream: string;
34
+ readonly host: string;
49
35
  readonly group: string;
50
- readonly workerBatchTasksCount: number;
51
- readonly recoveryStuckTasksTimeoutMs: number;
52
- readonly workerLoopIntervalMs: number;
53
- readonly workerSelectionTimeoutMs: number;
54
- readonly workerMaxRetries: number;
55
- readonly workerClearAttemptsTimeoutMs: number;
56
- onSelected(data: Array<[string, any[], number, string, string]>): Promise<[string, any[], number, string, string][]>;
57
- onExecute(id: string, payload: any, createdAt: number, job: string, key: string, attempt: number): Promise<void>;
58
- onReady(data: Array<[string, any[], number, string, string]>): Promise<void>;
59
- onSuccess(id: string, payload: any, createdAt: number, job: string, key: string): Promise<void>;
60
- onBatchError(err: any, tasks?: Array<[string, any[], number, string, string]>): Promise<void>;
61
- onError(err: any, id: string, payload: any, createdAt: number, job: string, key: string): Promise<void>;
62
- onRetry(err: any, id: string, payload: any, createdAt: number, job: string, key: string, attempts: number): Promise<void>;
63
- runQueue(): Promise<void>;
64
- consumerLoop(): Promise<void>;
65
- addTasks(queueName: string, data: any[], opts?: AddTasksOptions): Promise<string[]>;
66
- loadScripts(full?: boolean): Promise<void>;
67
- private loadScript;
68
- private saveScript;
69
- private runScript;
70
- private xaddBatch;
71
- private payloadBatch;
72
- private buildBatches;
73
- private keysLength;
74
- private attemptsKey;
75
- private incrAttempts;
76
- private getAttempts;
77
- private clearAttempts;
78
- private success;
36
+ readonly selectStuckCount: number;
37
+ readonly selectStuckTimeout: number;
38
+ readonly selectStuckMaxTimeout: number;
39
+ readonly selectCount: number;
40
+ readonly selectTimeout: number;
41
+ readonly buildBatchCount: number;
42
+ readonly buildBatchMaxCount: number;
43
+ readonly retryCount: number;
44
+ readonly executeSync: boolean;
45
+ readonly idemLockTimeout: number;
46
+ readonly idemDoneTimeout: number;
47
+ readonly logStatus: boolean;
48
+ readonly logStatusTimeout: number;
49
+ readonly approveCount: number;
50
+ readonly removeOnExecuted: boolean;
51
+ private signal;
52
+ private consumer;
53
+ runQueue(queueName: string, from?: '$' | '0-0'): Promise<void>;
54
+ createGroup(queueName: string, from?: '$' | '0-0'): Promise<void>;
55
+ consumerLoop(queueName: string, from?: '$' | '0-0'): Promise<void>;
79
56
  private batchError;
80
- private error;
81
- private attempt;
57
+ private approve;
58
+ select(queueName: string, from?: '$' | '0-0'): Promise<any[]>;
59
+ private selectS;
60
+ private selectF;
61
+ private selectP;
62
+ private values;
63
+ private payload;
82
64
  private execute;
83
65
  private executeProcess;
84
- private approve;
85
- private idempotency;
86
66
  private idempotencyKeys;
87
67
  private idempotencyAllow;
88
68
  private idempotencyStart;
89
69
  private idempotencyDone;
90
70
  private idempotencyFree;
91
- private createGroup;
92
- private select;
93
- private selectStuck;
94
- private selectFresh;
71
+ private success;
72
+ private error;
95
73
  private waitAbortable;
96
74
  private sendHeartbeat;
97
75
  private heartbeat;
98
- private normalizeEntries;
99
- private values;
100
- private payload;
101
- private signal;
102
- private consumer;
76
+ private runScript;
77
+ loadScripts(full?: boolean): Promise<void>;
78
+ private loadScript;
79
+ private saveScript;
80
+ addTasks(queueName: string, data: any[], opts?: AddTasksOptions): Promise<string[]>;
81
+ private buildBatches;
82
+ private keysLength;
83
+ private payloadBatch;
84
+ beforeExecute(queueName: string, tasks: Array<[string, any[], number, string, string, number]>): Promise<[string, any[], number, string, string, number][]>;
85
+ onExecute(queueName: string, task: Task): Promise<void>;
86
+ onBatchSuccess(queueName: string, tasks: Array<[string, any[], number, string, string, number]>): Promise<void>;
87
+ onSuccess(queueName: string, task: Task): Promise<void>;
88
+ onError(err: any, queueName: string, task: Task): Promise<void>;
89
+ onBatchError(err: any, queueName: string, tasks: Array<[string, any[], number, string, string, number]>): Promise<void>;
90
+ onRetry(err: any, queueName: string, task: Task): Promise<void>;
103
91
  }
104
92
 
105
93
  export { type AddTasksOptions, PowerQueues, type Task };