@remit/queue-sidecar 0.0.15 → 0.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/package.json +1 -1
- package/src/store.ts +19 -13
package/package.json
CHANGED
package/src/store.ts
CHANGED
|
@@ -508,6 +508,15 @@ export class QueueStore {
|
|
|
508
508
|
* a FIFO group still sees it after anything sent since.
|
|
509
509
|
*/
|
|
510
510
|
redriveDeadLetters(deadLetterName: string, now = Date.now()): number {
|
|
511
|
+
return this.db.transaction(
|
|
512
|
+
(): number => this.moveDeadLetters(deadLetterName, now),
|
|
513
|
+
IMMEDIATE,
|
|
514
|
+
);
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
// The body of a redrive, for a caller already inside a transaction:
|
|
518
|
+
// node:sqlite cannot begin one inside another.
|
|
519
|
+
private moveDeadLetters(deadLetterName: string, now: number): number {
|
|
511
520
|
this.requireQueue(deadLetterName);
|
|
512
521
|
const source = this.listQueues().find(
|
|
513
522
|
(queue) => queue.deadLetterTargetName === deadLetterName,
|
|
@@ -517,18 +526,14 @@ export class QueueStore {
|
|
|
517
526
|
`${deadLetterName} is not the dead-letter queue of any queue`,
|
|
518
527
|
);
|
|
519
528
|
}
|
|
520
|
-
const
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
.all();
|
|
529
|
-
for (const row of rows) this.moveToQueue(row, destination, now);
|
|
530
|
-
return rows.length;
|
|
531
|
-
}, IMMEDIATE);
|
|
529
|
+
const rows = this.db
|
|
530
|
+
.select()
|
|
531
|
+
.from(messages)
|
|
532
|
+
.where(eq(messages.queueName, deadLetterName))
|
|
533
|
+
.orderBy(asc(messages.id))
|
|
534
|
+
.all();
|
|
535
|
+
for (const row of rows) this.moveToQueue(row, source.name, now);
|
|
536
|
+
return rows.length;
|
|
532
537
|
}
|
|
533
538
|
|
|
534
539
|
redriveForRelease(release: string, deadLetterNames: string[]): void {
|
|
@@ -539,7 +544,8 @@ export class QueueStore {
|
|
|
539
544
|
.where(eq(releaseRedrive.id, 1))
|
|
540
545
|
.get();
|
|
541
546
|
if (marker?.release === release) return;
|
|
542
|
-
|
|
547
|
+
const now = Date.now();
|
|
548
|
+
for (const name of deadLetterNames) this.moveDeadLetters(name, now);
|
|
543
549
|
this.db
|
|
544
550
|
.insert(releaseRedrive)
|
|
545
551
|
.values({ id: 1, release })
|