@devbro/pashmak 0.1.24 → 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.
@@ -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 q.table(this.config.queue_table).whereOp("channel", "in", Array.from(this.channels.keys())).whereOp("status", "in", ["pending", "failed"]).limit(this.config.message_limit).orderBy("last_tried_at", "asc").get();
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
- let callback = this.channels.get(msg.channel);
510
- await callback(msg.message);
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
- last_tried_at: /* @__PURE__ */ new Date(),
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
  }
@@ -527,8 +536,6 @@ var DatabaseTransport = class {
527
536
  logger().error("Error in DatabaseTransport listen interval:", {
528
537
  error
529
538
  });
530
- } finally {
531
- await conn.disconnect();
532
539
  }
533
540
  });
534
541
  }, "processMessage");
@@ -541,27 +548,21 @@ var DatabaseTransport = class {
541
548
  }
542
549
  async dispatch(channel, message) {
543
550
  const conn = db(this.config.db_connection);
544
- try {
545
- await conn.connect();
546
- let schema = conn.getSchema();
547
- if (await schema.tableExists(this.config.queue_table) === false) {
548
- return;
549
- }
550
- let q = conn.getQuery();
551
- await q.table(this.config.queue_table).insert({
552
- channel,
553
- message,
554
- processed: false,
555
- created_at: /* @__PURE__ */ new Date(),
556
- updated_at: /* @__PURE__ */ new Date(),
557
- last_tried_at: null,
558
- process_message: "",
559
- retried_count: 0,
560
- status: "pending"
561
- });
562
- } finally {
563
- await conn.disconnect();
551
+ let schema = conn.getSchema();
552
+ if (await schema.tableExists(this.config.queue_table) === false) {
553
+ return;
564
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
+ });
565
566
  }
566
567
  async registerListener(channel, callback) {
567
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 q.table(this.config.queue_table).whereOp("channel", "in", Array.from(this.channels.keys())).whereOp("status", "in", ["pending", "failed"]).limit(this.config.message_limit).orderBy("last_tried_at", "asc").get();
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
- let callback = this.channels.get(msg.channel);
513
- await callback(msg.message);
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
- last_tried_at: /* @__PURE__ */ new Date(),
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
  }
@@ -530,8 +539,6 @@ var DatabaseTransport = class {
530
539
  logger().error("Error in DatabaseTransport listen interval:", {
531
540
  error
532
541
  });
533
- } finally {
534
- await conn.disconnect();
535
542
  }
536
543
  });
537
544
  }, "processMessage");
@@ -544,27 +551,21 @@ var DatabaseTransport = class {
544
551
  }
545
552
  async dispatch(channel, message) {
546
553
  const conn = db(this.config.db_connection);
547
- try {
548
- await conn.connect();
549
- let schema = conn.getSchema();
550
- if (await schema.tableExists(this.config.queue_table) === false) {
551
- return;
552
- }
553
- let q = conn.getQuery();
554
- await q.table(this.config.queue_table).insert({
555
- channel,
556
- message,
557
- processed: false,
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
- });
565
- } finally {
566
- await conn.disconnect();
554
+ let schema = conn.getSchema();
555
+ if (await schema.tableExists(this.config.queue_table) === false) {
556
+ return;
567
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
+ });
568
569
  }
569
570
  async registerListener(channel, callback) {
570
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 q.table(this.config.queue_table).whereOp("channel", "in", Array.from(this.channels.keys())).whereOp("status", "in", ["pending", "failed"]).limit(this.config.message_limit).orderBy("last_tried_at", "asc").get();
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
- let callback = this.channels.get(msg.channel);
511
- await callback(msg.message);
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
- last_tried_at: /* @__PURE__ */ new Date(),
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
  }
@@ -528,8 +537,6 @@ var DatabaseTransport = class {
528
537
  logger().error("Error in DatabaseTransport listen interval:", {
529
538
  error
530
539
  });
531
- } finally {
532
- await conn.disconnect();
533
540
  }
534
541
  });
535
542
  }, "processMessage");
@@ -542,27 +549,21 @@ var DatabaseTransport = class {
542
549
  }
543
550
  async dispatch(channel, message) {
544
551
  const conn = db(this.config.db_connection);
545
- try {
546
- await conn.connect();
547
- let schema = conn.getSchema();
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();
552
+ let schema = conn.getSchema();
553
+ if (await schema.tableExists(this.config.queue_table) === false) {
554
+ return;
565
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
+ });
566
567
  }
567
568
  async registerListener(channel, callback) {
568
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 q.table(this.config.queue_table).whereOp("channel", "in", Array.from(this.channels.keys())).whereOp("status", "in", ["pending", "failed"]).limit(this.config.message_limit).orderBy("last_tried_at", "asc").get();
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
- let callback = this.channels.get(msg.channel);
509
- await callback(msg.message);
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
- last_tried_at: /* @__PURE__ */ new Date(),
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
  }
@@ -526,8 +535,6 @@ var DatabaseTransport = class {
526
535
  logger().error("Error in DatabaseTransport listen interval:", {
527
536
  error
528
537
  });
529
- } finally {
530
- await conn.disconnect();
531
538
  }
532
539
  });
533
540
  }, "processMessage");
@@ -540,27 +547,21 @@ var DatabaseTransport = class {
540
547
  }
541
548
  async dispatch(channel, message) {
542
549
  const conn = db(this.config.db_connection);
543
- try {
544
- await conn.connect();
545
- let schema = conn.getSchema();
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();
550
+ let schema = conn.getSchema();
551
+ if (await schema.tableExists(this.config.queue_table) === false) {
552
+ return;
563
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
+ });
564
565
  }
565
566
  async registerListener(channel, callback) {
566
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 q.table(this.config.queue_table).whereOp("channel", "in", Array.from(this.channels.keys())).whereOp("status", "in", ["pending", "failed"]).limit(this.config.message_limit).orderBy("last_tried_at", "asc").get();
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
- let callback = this.channels.get(msg.channel);
509
- await callback(msg.message);
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
- last_tried_at: /* @__PURE__ */ new Date(),
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
  }
@@ -526,8 +535,6 @@ var DatabaseTransport = class {
526
535
  logger().error("Error in DatabaseTransport listen interval:", {
527
536
  error
528
537
  });
529
- } finally {
530
- await conn.disconnect();
531
538
  }
532
539
  });
533
540
  }, "processMessage");
@@ -540,27 +547,21 @@ var DatabaseTransport = class {
540
547
  }
541
548
  async dispatch(channel, message) {
542
549
  const conn = db(this.config.db_connection);
543
- try {
544
- await conn.connect();
545
- let schema = conn.getSchema();
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();
550
+ let schema = conn.getSchema();
551
+ if (await schema.tableExists(this.config.queue_table) === false) {
552
+ return;
563
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
+ });
564
565
  }
565
566
  async registerListener(channel, callback) {
566
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 q.table(this.config.queue_table).whereOp("channel", "in", Array.from(this.channels.keys())).whereOp("status", "in", ["pending", "failed"]).limit(this.config.message_limit).orderBy("last_tried_at", "asc").get();
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
- let callback = this.channels.get(msg.channel);
1672
- await callback(msg.message);
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
- last_tried_at: /* @__PURE__ */ new Date(),
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
  }
@@ -1689,8 +1698,6 @@ var DatabaseTransport = class {
1689
1698
  logger().error("Error in DatabaseTransport listen interval:", {
1690
1699
  error
1691
1700
  });
1692
- } finally {
1693
- await conn.disconnect();
1694
1701
  }
1695
1702
  });
1696
1703
  }, "processMessage");
@@ -1703,27 +1710,21 @@ var DatabaseTransport = class {
1703
1710
  }
1704
1711
  async dispatch(channel, message) {
1705
1712
  const conn = db(this.config.db_connection);
1706
- try {
1707
- await conn.connect();
1708
- let schema = conn.getSchema();
1709
- if (await schema.tableExists(this.config.queue_table) === false) {
1710
- return;
1711
- }
1712
- let q = conn.getQuery();
1713
- await q.table(this.config.queue_table).insert({
1714
- channel,
1715
- message,
1716
- processed: false,
1717
- created_at: /* @__PURE__ */ new Date(),
1718
- updated_at: /* @__PURE__ */ new Date(),
1719
- last_tried_at: null,
1720
- process_message: "",
1721
- retried_count: 0,
1722
- status: "pending"
1723
- });
1724
- } finally {
1725
- await conn.disconnect();
1713
+ let schema = conn.getSchema();
1714
+ if (await schema.tableExists(this.config.queue_table) === false) {
1715
+ return;
1726
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
+ });
1727
1728
  }
1728
1729
  async registerListener(channel, callback) {
1729
1730
  this.channels.set(channel, callback);