@devbro/pashmak 0.1.25 → 0.1.26
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/bin/app/console/DefaultCommand.cjs +32 -29
- package/dist/bin/app/console/KeyGenerateCommand.cjs +32 -29
- package/dist/bin/app/console/StartCommand.cjs +32 -29
- package/dist/bin/app/console/generate/GenerateControllerCommand.cjs +32 -29
- package/dist/bin/app/console/generate/index.cjs +32 -29
- package/dist/bin/app/console/index.cjs +32 -29
- package/dist/bin/app/console/migrate/GenerateMigrateCommand.cjs +32 -29
- package/dist/bin/app/console/migrate/MigrateCommand.cjs +32 -29
- package/dist/bin/app/console/migrate/MigrateRollbackCommand.cjs +32 -29
- package/dist/bin/app/console/migrate/index.cjs +32 -29
- package/dist/bin/app/console/queue/GenerateQueueMigrateCommand.cjs +32 -29
- package/dist/bin/cache.cjs +32 -29
- package/dist/bin/facades.cjs +32 -29
- package/dist/bin/factories.cjs +32 -29
- package/dist/bin/index.cjs +32 -29
- package/dist/bin/middlewares.cjs +32 -29
- package/dist/bin/queue.cjs +32 -29
- package/dist/queue.d.mts +1 -0
- package/dist/queue.mjs +32 -29
- package/dist/queue.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -491,8 +491,10 @@ var DatabaseTransport = class {
|
|
|
491
491
|
db_connection: "default",
|
|
492
492
|
listen_interval: 60,
|
|
493
493
|
// seconds
|
|
494
|
-
message_limit: 10
|
|
494
|
+
message_limit: 10,
|
|
495
495
|
// messages per each fetch
|
|
496
|
+
max_retry_count: 5
|
|
497
|
+
// maximum retry count for failed messages
|
|
496
498
|
};
|
|
497
499
|
channels = /* @__PURE__ */ new Map();
|
|
498
500
|
messageQueues = [];
|
|
@@ -501,24 +503,31 @@ var DatabaseTransport = class {
|
|
|
501
503
|
await import_neko_context2.context_provider.run(async () => {
|
|
502
504
|
const conn = db(this.config.db_connection);
|
|
503
505
|
try {
|
|
504
|
-
await conn.connect();
|
|
505
506
|
let q = conn.getQuery();
|
|
506
|
-
let messages = await
|
|
507
|
+
let messages = await conn.getQuery().table(this.config.queue_table).whereOp("channel", "in", Array.from(this.channels.keys())).whereOp("status", "in", ["pending", "failed"]).whereOp("retried_count", "<", this.config.max_retry_count).limit(this.config.message_limit).orderBy("last_tried_at", "asc").get();
|
|
507
508
|
for (let msg of messages) {
|
|
508
509
|
try {
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
await q.table(this.config.queue_table).whereOp("id", "=", msg.id).update({
|
|
512
|
-
status: "processed",
|
|
510
|
+
await conn.getQuery().table(this.config.queue_table).whereOp("id", "=", msg.id).update({
|
|
511
|
+
status: "processing",
|
|
513
512
|
updated_at: /* @__PURE__ */ new Date(),
|
|
514
513
|
last_tried_at: /* @__PURE__ */ new Date(),
|
|
515
514
|
retried_count: (msg.retried_count || 0) + 1
|
|
516
515
|
});
|
|
516
|
+
let callback = this.channels.get(msg.channel);
|
|
517
|
+
await callback(msg.message);
|
|
518
|
+
await conn.getQuery().table(this.config.queue_table).whereOp("id", "=", msg.id).update({
|
|
519
|
+
status: "processed",
|
|
520
|
+
updated_at: /* @__PURE__ */ new Date()
|
|
521
|
+
});
|
|
517
522
|
} catch (error) {
|
|
523
|
+
logger().error("Error processing message:", {
|
|
524
|
+
error,
|
|
525
|
+
message_id: msg.id,
|
|
526
|
+
channel: msg.channel
|
|
527
|
+
});
|
|
518
528
|
await q.table(this.config.queue_table).whereOp("id", "=", msg.id).update({
|
|
519
529
|
status: "failed",
|
|
520
|
-
|
|
521
|
-
retried_count: (msg.retried_count || 0) + 1,
|
|
530
|
+
updated_at: /* @__PURE__ */ new Date(),
|
|
522
531
|
process_message: error.message || "Error processing message"
|
|
523
532
|
});
|
|
524
533
|
}
|
|
@@ -539,27 +548,21 @@ var DatabaseTransport = class {
|
|
|
539
548
|
}
|
|
540
549
|
async dispatch(channel, message) {
|
|
541
550
|
const conn = db(this.config.db_connection);
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
if (await schema.tableExists(this.config.queue_table) === false) {
|
|
546
|
-
return;
|
|
547
|
-
}
|
|
548
|
-
let q = conn.getQuery();
|
|
549
|
-
await q.table(this.config.queue_table).insert({
|
|
550
|
-
channel,
|
|
551
|
-
message,
|
|
552
|
-
processed: false,
|
|
553
|
-
created_at: /* @__PURE__ */ new Date(),
|
|
554
|
-
updated_at: /* @__PURE__ */ new Date(),
|
|
555
|
-
last_tried_at: null,
|
|
556
|
-
process_message: "",
|
|
557
|
-
retried_count: 0,
|
|
558
|
-
status: "pending"
|
|
559
|
-
});
|
|
560
|
-
} finally {
|
|
561
|
-
await conn.disconnect();
|
|
551
|
+
let schema = conn.getSchema();
|
|
552
|
+
if (await schema.tableExists(this.config.queue_table) === false) {
|
|
553
|
+
return;
|
|
562
554
|
}
|
|
555
|
+
let q = conn.getQuery();
|
|
556
|
+
await q.table(this.config.queue_table).insert({
|
|
557
|
+
channel,
|
|
558
|
+
message,
|
|
559
|
+
created_at: /* @__PURE__ */ new Date(),
|
|
560
|
+
updated_at: /* @__PURE__ */ new Date(),
|
|
561
|
+
last_tried_at: null,
|
|
562
|
+
process_message: "",
|
|
563
|
+
retried_count: 0,
|
|
564
|
+
status: "pending"
|
|
565
|
+
});
|
|
563
566
|
}
|
|
564
567
|
async registerListener(channel, callback) {
|
|
565
568
|
this.channels.set(channel, callback);
|
|
@@ -494,8 +494,10 @@ var DatabaseTransport = class {
|
|
|
494
494
|
db_connection: "default",
|
|
495
495
|
listen_interval: 60,
|
|
496
496
|
// seconds
|
|
497
|
-
message_limit: 10
|
|
497
|
+
message_limit: 10,
|
|
498
498
|
// messages per each fetch
|
|
499
|
+
max_retry_count: 5
|
|
500
|
+
// maximum retry count for failed messages
|
|
499
501
|
};
|
|
500
502
|
channels = /* @__PURE__ */ new Map();
|
|
501
503
|
messageQueues = [];
|
|
@@ -504,24 +506,31 @@ var DatabaseTransport = class {
|
|
|
504
506
|
await import_neko_context2.context_provider.run(async () => {
|
|
505
507
|
const conn = db(this.config.db_connection);
|
|
506
508
|
try {
|
|
507
|
-
await conn.connect();
|
|
508
509
|
let q = conn.getQuery();
|
|
509
|
-
let messages = await
|
|
510
|
+
let messages = await conn.getQuery().table(this.config.queue_table).whereOp("channel", "in", Array.from(this.channels.keys())).whereOp("status", "in", ["pending", "failed"]).whereOp("retried_count", "<", this.config.max_retry_count).limit(this.config.message_limit).orderBy("last_tried_at", "asc").get();
|
|
510
511
|
for (let msg of messages) {
|
|
511
512
|
try {
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
await q.table(this.config.queue_table).whereOp("id", "=", msg.id).update({
|
|
515
|
-
status: "processed",
|
|
513
|
+
await conn.getQuery().table(this.config.queue_table).whereOp("id", "=", msg.id).update({
|
|
514
|
+
status: "processing",
|
|
516
515
|
updated_at: /* @__PURE__ */ new Date(),
|
|
517
516
|
last_tried_at: /* @__PURE__ */ new Date(),
|
|
518
517
|
retried_count: (msg.retried_count || 0) + 1
|
|
519
518
|
});
|
|
519
|
+
let callback = this.channels.get(msg.channel);
|
|
520
|
+
await callback(msg.message);
|
|
521
|
+
await conn.getQuery().table(this.config.queue_table).whereOp("id", "=", msg.id).update({
|
|
522
|
+
status: "processed",
|
|
523
|
+
updated_at: /* @__PURE__ */ new Date()
|
|
524
|
+
});
|
|
520
525
|
} catch (error) {
|
|
526
|
+
logger().error("Error processing message:", {
|
|
527
|
+
error,
|
|
528
|
+
message_id: msg.id,
|
|
529
|
+
channel: msg.channel
|
|
530
|
+
});
|
|
521
531
|
await q.table(this.config.queue_table).whereOp("id", "=", msg.id).update({
|
|
522
532
|
status: "failed",
|
|
523
|
-
|
|
524
|
-
retried_count: (msg.retried_count || 0) + 1,
|
|
533
|
+
updated_at: /* @__PURE__ */ new Date(),
|
|
525
534
|
process_message: error.message || "Error processing message"
|
|
526
535
|
});
|
|
527
536
|
}
|
|
@@ -542,27 +551,21 @@ var DatabaseTransport = class {
|
|
|
542
551
|
}
|
|
543
552
|
async dispatch(channel, message) {
|
|
544
553
|
const conn = db(this.config.db_connection);
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
if (await schema.tableExists(this.config.queue_table) === false) {
|
|
549
|
-
return;
|
|
550
|
-
}
|
|
551
|
-
let q = conn.getQuery();
|
|
552
|
-
await q.table(this.config.queue_table).insert({
|
|
553
|
-
channel,
|
|
554
|
-
message,
|
|
555
|
-
processed: false,
|
|
556
|
-
created_at: /* @__PURE__ */ new Date(),
|
|
557
|
-
updated_at: /* @__PURE__ */ new Date(),
|
|
558
|
-
last_tried_at: null,
|
|
559
|
-
process_message: "",
|
|
560
|
-
retried_count: 0,
|
|
561
|
-
status: "pending"
|
|
562
|
-
});
|
|
563
|
-
} finally {
|
|
564
|
-
await conn.disconnect();
|
|
554
|
+
let schema = conn.getSchema();
|
|
555
|
+
if (await schema.tableExists(this.config.queue_table) === false) {
|
|
556
|
+
return;
|
|
565
557
|
}
|
|
558
|
+
let q = conn.getQuery();
|
|
559
|
+
await q.table(this.config.queue_table).insert({
|
|
560
|
+
channel,
|
|
561
|
+
message,
|
|
562
|
+
created_at: /* @__PURE__ */ new Date(),
|
|
563
|
+
updated_at: /* @__PURE__ */ new Date(),
|
|
564
|
+
last_tried_at: null,
|
|
565
|
+
process_message: "",
|
|
566
|
+
retried_count: 0,
|
|
567
|
+
status: "pending"
|
|
568
|
+
});
|
|
566
569
|
}
|
|
567
570
|
async registerListener(channel, callback) {
|
|
568
571
|
this.channels.set(channel, callback);
|
|
@@ -492,8 +492,10 @@ var DatabaseTransport = class {
|
|
|
492
492
|
db_connection: "default",
|
|
493
493
|
listen_interval: 60,
|
|
494
494
|
// seconds
|
|
495
|
-
message_limit: 10
|
|
495
|
+
message_limit: 10,
|
|
496
496
|
// messages per each fetch
|
|
497
|
+
max_retry_count: 5
|
|
498
|
+
// maximum retry count for failed messages
|
|
497
499
|
};
|
|
498
500
|
channels = /* @__PURE__ */ new Map();
|
|
499
501
|
messageQueues = [];
|
|
@@ -502,24 +504,31 @@ var DatabaseTransport = class {
|
|
|
502
504
|
await import_neko_context2.context_provider.run(async () => {
|
|
503
505
|
const conn = db(this.config.db_connection);
|
|
504
506
|
try {
|
|
505
|
-
await conn.connect();
|
|
506
507
|
let q = conn.getQuery();
|
|
507
|
-
let messages = await
|
|
508
|
+
let messages = await conn.getQuery().table(this.config.queue_table).whereOp("channel", "in", Array.from(this.channels.keys())).whereOp("status", "in", ["pending", "failed"]).whereOp("retried_count", "<", this.config.max_retry_count).limit(this.config.message_limit).orderBy("last_tried_at", "asc").get();
|
|
508
509
|
for (let msg of messages) {
|
|
509
510
|
try {
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
await q.table(this.config.queue_table).whereOp("id", "=", msg.id).update({
|
|
513
|
-
status: "processed",
|
|
511
|
+
await conn.getQuery().table(this.config.queue_table).whereOp("id", "=", msg.id).update({
|
|
512
|
+
status: "processing",
|
|
514
513
|
updated_at: /* @__PURE__ */ new Date(),
|
|
515
514
|
last_tried_at: /* @__PURE__ */ new Date(),
|
|
516
515
|
retried_count: (msg.retried_count || 0) + 1
|
|
517
516
|
});
|
|
517
|
+
let callback = this.channels.get(msg.channel);
|
|
518
|
+
await callback(msg.message);
|
|
519
|
+
await conn.getQuery().table(this.config.queue_table).whereOp("id", "=", msg.id).update({
|
|
520
|
+
status: "processed",
|
|
521
|
+
updated_at: /* @__PURE__ */ new Date()
|
|
522
|
+
});
|
|
518
523
|
} catch (error) {
|
|
524
|
+
logger().error("Error processing message:", {
|
|
525
|
+
error,
|
|
526
|
+
message_id: msg.id,
|
|
527
|
+
channel: msg.channel
|
|
528
|
+
});
|
|
519
529
|
await q.table(this.config.queue_table).whereOp("id", "=", msg.id).update({
|
|
520
530
|
status: "failed",
|
|
521
|
-
|
|
522
|
-
retried_count: (msg.retried_count || 0) + 1,
|
|
531
|
+
updated_at: /* @__PURE__ */ new Date(),
|
|
523
532
|
process_message: error.message || "Error processing message"
|
|
524
533
|
});
|
|
525
534
|
}
|
|
@@ -540,27 +549,21 @@ var DatabaseTransport = class {
|
|
|
540
549
|
}
|
|
541
550
|
async dispatch(channel, message) {
|
|
542
551
|
const conn = db(this.config.db_connection);
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
if (await schema.tableExists(this.config.queue_table) === false) {
|
|
547
|
-
return;
|
|
548
|
-
}
|
|
549
|
-
let q = conn.getQuery();
|
|
550
|
-
await q.table(this.config.queue_table).insert({
|
|
551
|
-
channel,
|
|
552
|
-
message,
|
|
553
|
-
processed: false,
|
|
554
|
-
created_at: /* @__PURE__ */ new Date(),
|
|
555
|
-
updated_at: /* @__PURE__ */ new Date(),
|
|
556
|
-
last_tried_at: null,
|
|
557
|
-
process_message: "",
|
|
558
|
-
retried_count: 0,
|
|
559
|
-
status: "pending"
|
|
560
|
-
});
|
|
561
|
-
} finally {
|
|
562
|
-
await conn.disconnect();
|
|
552
|
+
let schema = conn.getSchema();
|
|
553
|
+
if (await schema.tableExists(this.config.queue_table) === false) {
|
|
554
|
+
return;
|
|
563
555
|
}
|
|
556
|
+
let q = conn.getQuery();
|
|
557
|
+
await q.table(this.config.queue_table).insert({
|
|
558
|
+
channel,
|
|
559
|
+
message,
|
|
560
|
+
created_at: /* @__PURE__ */ new Date(),
|
|
561
|
+
updated_at: /* @__PURE__ */ new Date(),
|
|
562
|
+
last_tried_at: null,
|
|
563
|
+
process_message: "",
|
|
564
|
+
retried_count: 0,
|
|
565
|
+
status: "pending"
|
|
566
|
+
});
|
|
564
567
|
}
|
|
565
568
|
async registerListener(channel, callback) {
|
|
566
569
|
this.channels.set(channel, callback);
|
|
@@ -490,8 +490,10 @@ var DatabaseTransport = class {
|
|
|
490
490
|
db_connection: "default",
|
|
491
491
|
listen_interval: 60,
|
|
492
492
|
// seconds
|
|
493
|
-
message_limit: 10
|
|
493
|
+
message_limit: 10,
|
|
494
494
|
// messages per each fetch
|
|
495
|
+
max_retry_count: 5
|
|
496
|
+
// maximum retry count for failed messages
|
|
495
497
|
};
|
|
496
498
|
channels = /* @__PURE__ */ new Map();
|
|
497
499
|
messageQueues = [];
|
|
@@ -500,24 +502,31 @@ var DatabaseTransport = class {
|
|
|
500
502
|
await import_neko_context2.context_provider.run(async () => {
|
|
501
503
|
const conn = db(this.config.db_connection);
|
|
502
504
|
try {
|
|
503
|
-
await conn.connect();
|
|
504
505
|
let q = conn.getQuery();
|
|
505
|
-
let messages = await
|
|
506
|
+
let messages = await conn.getQuery().table(this.config.queue_table).whereOp("channel", "in", Array.from(this.channels.keys())).whereOp("status", "in", ["pending", "failed"]).whereOp("retried_count", "<", this.config.max_retry_count).limit(this.config.message_limit).orderBy("last_tried_at", "asc").get();
|
|
506
507
|
for (let msg of messages) {
|
|
507
508
|
try {
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
await q.table(this.config.queue_table).whereOp("id", "=", msg.id).update({
|
|
511
|
-
status: "processed",
|
|
509
|
+
await conn.getQuery().table(this.config.queue_table).whereOp("id", "=", msg.id).update({
|
|
510
|
+
status: "processing",
|
|
512
511
|
updated_at: /* @__PURE__ */ new Date(),
|
|
513
512
|
last_tried_at: /* @__PURE__ */ new Date(),
|
|
514
513
|
retried_count: (msg.retried_count || 0) + 1
|
|
515
514
|
});
|
|
515
|
+
let callback = this.channels.get(msg.channel);
|
|
516
|
+
await callback(msg.message);
|
|
517
|
+
await conn.getQuery().table(this.config.queue_table).whereOp("id", "=", msg.id).update({
|
|
518
|
+
status: "processed",
|
|
519
|
+
updated_at: /* @__PURE__ */ new Date()
|
|
520
|
+
});
|
|
516
521
|
} catch (error) {
|
|
522
|
+
logger().error("Error processing message:", {
|
|
523
|
+
error,
|
|
524
|
+
message_id: msg.id,
|
|
525
|
+
channel: msg.channel
|
|
526
|
+
});
|
|
517
527
|
await q.table(this.config.queue_table).whereOp("id", "=", msg.id).update({
|
|
518
528
|
status: "failed",
|
|
519
|
-
|
|
520
|
-
retried_count: (msg.retried_count || 0) + 1,
|
|
529
|
+
updated_at: /* @__PURE__ */ new Date(),
|
|
521
530
|
process_message: error.message || "Error processing message"
|
|
522
531
|
});
|
|
523
532
|
}
|
|
@@ -538,27 +547,21 @@ var DatabaseTransport = class {
|
|
|
538
547
|
}
|
|
539
548
|
async dispatch(channel, message) {
|
|
540
549
|
const conn = db(this.config.db_connection);
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
if (await schema.tableExists(this.config.queue_table) === false) {
|
|
545
|
-
return;
|
|
546
|
-
}
|
|
547
|
-
let q = conn.getQuery();
|
|
548
|
-
await q.table(this.config.queue_table).insert({
|
|
549
|
-
channel,
|
|
550
|
-
message,
|
|
551
|
-
processed: false,
|
|
552
|
-
created_at: /* @__PURE__ */ new Date(),
|
|
553
|
-
updated_at: /* @__PURE__ */ new Date(),
|
|
554
|
-
last_tried_at: null,
|
|
555
|
-
process_message: "",
|
|
556
|
-
retried_count: 0,
|
|
557
|
-
status: "pending"
|
|
558
|
-
});
|
|
559
|
-
} finally {
|
|
560
|
-
await conn.disconnect();
|
|
550
|
+
let schema = conn.getSchema();
|
|
551
|
+
if (await schema.tableExists(this.config.queue_table) === false) {
|
|
552
|
+
return;
|
|
561
553
|
}
|
|
554
|
+
let q = conn.getQuery();
|
|
555
|
+
await q.table(this.config.queue_table).insert({
|
|
556
|
+
channel,
|
|
557
|
+
message,
|
|
558
|
+
created_at: /* @__PURE__ */ new Date(),
|
|
559
|
+
updated_at: /* @__PURE__ */ new Date(),
|
|
560
|
+
last_tried_at: null,
|
|
561
|
+
process_message: "",
|
|
562
|
+
retried_count: 0,
|
|
563
|
+
status: "pending"
|
|
564
|
+
});
|
|
562
565
|
}
|
|
563
566
|
async registerListener(channel, callback) {
|
|
564
567
|
this.channels.set(channel, callback);
|
|
@@ -490,8 +490,10 @@ var DatabaseTransport = class {
|
|
|
490
490
|
db_connection: "default",
|
|
491
491
|
listen_interval: 60,
|
|
492
492
|
// seconds
|
|
493
|
-
message_limit: 10
|
|
493
|
+
message_limit: 10,
|
|
494
494
|
// messages per each fetch
|
|
495
|
+
max_retry_count: 5
|
|
496
|
+
// maximum retry count for failed messages
|
|
495
497
|
};
|
|
496
498
|
channels = /* @__PURE__ */ new Map();
|
|
497
499
|
messageQueues = [];
|
|
@@ -500,24 +502,31 @@ var DatabaseTransport = class {
|
|
|
500
502
|
await import_neko_context2.context_provider.run(async () => {
|
|
501
503
|
const conn = db(this.config.db_connection);
|
|
502
504
|
try {
|
|
503
|
-
await conn.connect();
|
|
504
505
|
let q = conn.getQuery();
|
|
505
|
-
let messages = await
|
|
506
|
+
let messages = await conn.getQuery().table(this.config.queue_table).whereOp("channel", "in", Array.from(this.channels.keys())).whereOp("status", "in", ["pending", "failed"]).whereOp("retried_count", "<", this.config.max_retry_count).limit(this.config.message_limit).orderBy("last_tried_at", "asc").get();
|
|
506
507
|
for (let msg of messages) {
|
|
507
508
|
try {
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
await q.table(this.config.queue_table).whereOp("id", "=", msg.id).update({
|
|
511
|
-
status: "processed",
|
|
509
|
+
await conn.getQuery().table(this.config.queue_table).whereOp("id", "=", msg.id).update({
|
|
510
|
+
status: "processing",
|
|
512
511
|
updated_at: /* @__PURE__ */ new Date(),
|
|
513
512
|
last_tried_at: /* @__PURE__ */ new Date(),
|
|
514
513
|
retried_count: (msg.retried_count || 0) + 1
|
|
515
514
|
});
|
|
515
|
+
let callback = this.channels.get(msg.channel);
|
|
516
|
+
await callback(msg.message);
|
|
517
|
+
await conn.getQuery().table(this.config.queue_table).whereOp("id", "=", msg.id).update({
|
|
518
|
+
status: "processed",
|
|
519
|
+
updated_at: /* @__PURE__ */ new Date()
|
|
520
|
+
});
|
|
516
521
|
} catch (error) {
|
|
522
|
+
logger().error("Error processing message:", {
|
|
523
|
+
error,
|
|
524
|
+
message_id: msg.id,
|
|
525
|
+
channel: msg.channel
|
|
526
|
+
});
|
|
517
527
|
await q.table(this.config.queue_table).whereOp("id", "=", msg.id).update({
|
|
518
528
|
status: "failed",
|
|
519
|
-
|
|
520
|
-
retried_count: (msg.retried_count || 0) + 1,
|
|
529
|
+
updated_at: /* @__PURE__ */ new Date(),
|
|
521
530
|
process_message: error.message || "Error processing message"
|
|
522
531
|
});
|
|
523
532
|
}
|
|
@@ -538,27 +547,21 @@ var DatabaseTransport = class {
|
|
|
538
547
|
}
|
|
539
548
|
async dispatch(channel, message) {
|
|
540
549
|
const conn = db(this.config.db_connection);
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
if (await schema.tableExists(this.config.queue_table) === false) {
|
|
545
|
-
return;
|
|
546
|
-
}
|
|
547
|
-
let q = conn.getQuery();
|
|
548
|
-
await q.table(this.config.queue_table).insert({
|
|
549
|
-
channel,
|
|
550
|
-
message,
|
|
551
|
-
processed: false,
|
|
552
|
-
created_at: /* @__PURE__ */ new Date(),
|
|
553
|
-
updated_at: /* @__PURE__ */ new Date(),
|
|
554
|
-
last_tried_at: null,
|
|
555
|
-
process_message: "",
|
|
556
|
-
retried_count: 0,
|
|
557
|
-
status: "pending"
|
|
558
|
-
});
|
|
559
|
-
} finally {
|
|
560
|
-
await conn.disconnect();
|
|
550
|
+
let schema = conn.getSchema();
|
|
551
|
+
if (await schema.tableExists(this.config.queue_table) === false) {
|
|
552
|
+
return;
|
|
561
553
|
}
|
|
554
|
+
let q = conn.getQuery();
|
|
555
|
+
await q.table(this.config.queue_table).insert({
|
|
556
|
+
channel,
|
|
557
|
+
message,
|
|
558
|
+
created_at: /* @__PURE__ */ new Date(),
|
|
559
|
+
updated_at: /* @__PURE__ */ new Date(),
|
|
560
|
+
last_tried_at: null,
|
|
561
|
+
process_message: "",
|
|
562
|
+
retried_count: 0,
|
|
563
|
+
status: "pending"
|
|
564
|
+
});
|
|
562
565
|
}
|
|
563
566
|
async registerListener(channel, callback) {
|
|
564
567
|
this.channels.set(channel, callback);
|
|
@@ -1653,8 +1653,10 @@ var DatabaseTransport = class {
|
|
|
1653
1653
|
db_connection: "default",
|
|
1654
1654
|
listen_interval: 60,
|
|
1655
1655
|
// seconds
|
|
1656
|
-
message_limit: 10
|
|
1656
|
+
message_limit: 10,
|
|
1657
1657
|
// messages per each fetch
|
|
1658
|
+
max_retry_count: 5
|
|
1659
|
+
// maximum retry count for failed messages
|
|
1658
1660
|
};
|
|
1659
1661
|
channels = /* @__PURE__ */ new Map();
|
|
1660
1662
|
messageQueues = [];
|
|
@@ -1663,24 +1665,31 @@ var DatabaseTransport = class {
|
|
|
1663
1665
|
await import_neko_context2.context_provider.run(async () => {
|
|
1664
1666
|
const conn = db(this.config.db_connection);
|
|
1665
1667
|
try {
|
|
1666
|
-
await conn.connect();
|
|
1667
1668
|
let q = conn.getQuery();
|
|
1668
|
-
let messages = await
|
|
1669
|
+
let messages = await conn.getQuery().table(this.config.queue_table).whereOp("channel", "in", Array.from(this.channels.keys())).whereOp("status", "in", ["pending", "failed"]).whereOp("retried_count", "<", this.config.max_retry_count).limit(this.config.message_limit).orderBy("last_tried_at", "asc").get();
|
|
1669
1670
|
for (let msg of messages) {
|
|
1670
1671
|
try {
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
await q.table(this.config.queue_table).whereOp("id", "=", msg.id).update({
|
|
1674
|
-
status: "processed",
|
|
1672
|
+
await conn.getQuery().table(this.config.queue_table).whereOp("id", "=", msg.id).update({
|
|
1673
|
+
status: "processing",
|
|
1675
1674
|
updated_at: /* @__PURE__ */ new Date(),
|
|
1676
1675
|
last_tried_at: /* @__PURE__ */ new Date(),
|
|
1677
1676
|
retried_count: (msg.retried_count || 0) + 1
|
|
1678
1677
|
});
|
|
1678
|
+
let callback = this.channels.get(msg.channel);
|
|
1679
|
+
await callback(msg.message);
|
|
1680
|
+
await conn.getQuery().table(this.config.queue_table).whereOp("id", "=", msg.id).update({
|
|
1681
|
+
status: "processed",
|
|
1682
|
+
updated_at: /* @__PURE__ */ new Date()
|
|
1683
|
+
});
|
|
1679
1684
|
} catch (error) {
|
|
1685
|
+
logger().error("Error processing message:", {
|
|
1686
|
+
error,
|
|
1687
|
+
message_id: msg.id,
|
|
1688
|
+
channel: msg.channel
|
|
1689
|
+
});
|
|
1680
1690
|
await q.table(this.config.queue_table).whereOp("id", "=", msg.id).update({
|
|
1681
1691
|
status: "failed",
|
|
1682
|
-
|
|
1683
|
-
retried_count: (msg.retried_count || 0) + 1,
|
|
1692
|
+
updated_at: /* @__PURE__ */ new Date(),
|
|
1684
1693
|
process_message: error.message || "Error processing message"
|
|
1685
1694
|
});
|
|
1686
1695
|
}
|
|
@@ -1701,27 +1710,21 @@ var DatabaseTransport = class {
|
|
|
1701
1710
|
}
|
|
1702
1711
|
async dispatch(channel, message) {
|
|
1703
1712
|
const conn = db(this.config.db_connection);
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
if (await schema.tableExists(this.config.queue_table) === false) {
|
|
1708
|
-
return;
|
|
1709
|
-
}
|
|
1710
|
-
let q = conn.getQuery();
|
|
1711
|
-
await q.table(this.config.queue_table).insert({
|
|
1712
|
-
channel,
|
|
1713
|
-
message,
|
|
1714
|
-
processed: false,
|
|
1715
|
-
created_at: /* @__PURE__ */ new Date(),
|
|
1716
|
-
updated_at: /* @__PURE__ */ new Date(),
|
|
1717
|
-
last_tried_at: null,
|
|
1718
|
-
process_message: "",
|
|
1719
|
-
retried_count: 0,
|
|
1720
|
-
status: "pending"
|
|
1721
|
-
});
|
|
1722
|
-
} finally {
|
|
1723
|
-
await conn.disconnect();
|
|
1713
|
+
let schema = conn.getSchema();
|
|
1714
|
+
if (await schema.tableExists(this.config.queue_table) === false) {
|
|
1715
|
+
return;
|
|
1724
1716
|
}
|
|
1717
|
+
let q = conn.getQuery();
|
|
1718
|
+
await q.table(this.config.queue_table).insert({
|
|
1719
|
+
channel,
|
|
1720
|
+
message,
|
|
1721
|
+
created_at: /* @__PURE__ */ new Date(),
|
|
1722
|
+
updated_at: /* @__PURE__ */ new Date(),
|
|
1723
|
+
last_tried_at: null,
|
|
1724
|
+
process_message: "",
|
|
1725
|
+
retried_count: 0,
|
|
1726
|
+
status: "pending"
|
|
1727
|
+
});
|
|
1725
1728
|
}
|
|
1726
1729
|
async registerListener(channel, callback) {
|
|
1727
1730
|
this.channels.set(channel, callback);
|
|
@@ -490,8 +490,10 @@ var DatabaseTransport = class {
|
|
|
490
490
|
db_connection: "default",
|
|
491
491
|
listen_interval: 60,
|
|
492
492
|
// seconds
|
|
493
|
-
message_limit: 10
|
|
493
|
+
message_limit: 10,
|
|
494
494
|
// messages per each fetch
|
|
495
|
+
max_retry_count: 5
|
|
496
|
+
// maximum retry count for failed messages
|
|
495
497
|
};
|
|
496
498
|
channels = /* @__PURE__ */ new Map();
|
|
497
499
|
messageQueues = [];
|
|
@@ -500,24 +502,31 @@ var DatabaseTransport = class {
|
|
|
500
502
|
await import_neko_context2.context_provider.run(async () => {
|
|
501
503
|
const conn = db(this.config.db_connection);
|
|
502
504
|
try {
|
|
503
|
-
await conn.connect();
|
|
504
505
|
let q = conn.getQuery();
|
|
505
|
-
let messages = await
|
|
506
|
+
let messages = await conn.getQuery().table(this.config.queue_table).whereOp("channel", "in", Array.from(this.channels.keys())).whereOp("status", "in", ["pending", "failed"]).whereOp("retried_count", "<", this.config.max_retry_count).limit(this.config.message_limit).orderBy("last_tried_at", "asc").get();
|
|
506
507
|
for (let msg of messages) {
|
|
507
508
|
try {
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
await q.table(this.config.queue_table).whereOp("id", "=", msg.id).update({
|
|
511
|
-
status: "processed",
|
|
509
|
+
await conn.getQuery().table(this.config.queue_table).whereOp("id", "=", msg.id).update({
|
|
510
|
+
status: "processing",
|
|
512
511
|
updated_at: /* @__PURE__ */ new Date(),
|
|
513
512
|
last_tried_at: /* @__PURE__ */ new Date(),
|
|
514
513
|
retried_count: (msg.retried_count || 0) + 1
|
|
515
514
|
});
|
|
515
|
+
let callback = this.channels.get(msg.channel);
|
|
516
|
+
await callback(msg.message);
|
|
517
|
+
await conn.getQuery().table(this.config.queue_table).whereOp("id", "=", msg.id).update({
|
|
518
|
+
status: "processed",
|
|
519
|
+
updated_at: /* @__PURE__ */ new Date()
|
|
520
|
+
});
|
|
516
521
|
} catch (error) {
|
|
522
|
+
logger().error("Error processing message:", {
|
|
523
|
+
error,
|
|
524
|
+
message_id: msg.id,
|
|
525
|
+
channel: msg.channel
|
|
526
|
+
});
|
|
517
527
|
await q.table(this.config.queue_table).whereOp("id", "=", msg.id).update({
|
|
518
528
|
status: "failed",
|
|
519
|
-
|
|
520
|
-
retried_count: (msg.retried_count || 0) + 1,
|
|
529
|
+
updated_at: /* @__PURE__ */ new Date(),
|
|
521
530
|
process_message: error.message || "Error processing message"
|
|
522
531
|
});
|
|
523
532
|
}
|
|
@@ -538,27 +547,21 @@ var DatabaseTransport = class {
|
|
|
538
547
|
}
|
|
539
548
|
async dispatch(channel, message) {
|
|
540
549
|
const conn = db(this.config.db_connection);
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
if (await schema.tableExists(this.config.queue_table) === false) {
|
|
545
|
-
return;
|
|
546
|
-
}
|
|
547
|
-
let q = conn.getQuery();
|
|
548
|
-
await q.table(this.config.queue_table).insert({
|
|
549
|
-
channel,
|
|
550
|
-
message,
|
|
551
|
-
processed: false,
|
|
552
|
-
created_at: /* @__PURE__ */ new Date(),
|
|
553
|
-
updated_at: /* @__PURE__ */ new Date(),
|
|
554
|
-
last_tried_at: null,
|
|
555
|
-
process_message: "",
|
|
556
|
-
retried_count: 0,
|
|
557
|
-
status: "pending"
|
|
558
|
-
});
|
|
559
|
-
} finally {
|
|
560
|
-
await conn.disconnect();
|
|
550
|
+
let schema = conn.getSchema();
|
|
551
|
+
if (await schema.tableExists(this.config.queue_table) === false) {
|
|
552
|
+
return;
|
|
561
553
|
}
|
|
554
|
+
let q = conn.getQuery();
|
|
555
|
+
await q.table(this.config.queue_table).insert({
|
|
556
|
+
channel,
|
|
557
|
+
message,
|
|
558
|
+
created_at: /* @__PURE__ */ new Date(),
|
|
559
|
+
updated_at: /* @__PURE__ */ new Date(),
|
|
560
|
+
last_tried_at: null,
|
|
561
|
+
process_message: "",
|
|
562
|
+
retried_count: 0,
|
|
563
|
+
status: "pending"
|
|
564
|
+
});
|
|
562
565
|
}
|
|
563
566
|
async registerListener(channel, callback) {
|
|
564
567
|
this.channels.set(channel, callback);
|