File tree Expand file tree Collapse file tree 6 files changed +11
-13
lines changed
Expand file tree Collapse file tree 6 files changed +11
-13
lines changed Original file line number Diff line number Diff line change @@ -93,9 +93,6 @@ class AmqpAdapter extends BaseAdapter {
9393 . map ( s => s . trim ( ) ) ;
9494 }
9595
96- this . error2ErrorInfoParser =
97- this . opts ?. deadLettering ?. error2ErrorInfoParser || error2ErrorInfoParser ;
98-
9996 /** @type {AMQPLibConnection } */
10097 this . connection = null ;
10198 /** @type {AMQPLibChannel } */
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ const semver = require("semver");
1111const { MoleculerError } = require ( "moleculer" ) . Errors ;
1212const { Serializers, METRIC } = require ( "moleculer" ) ;
1313const C = require ( "../constants" ) ;
14+ const { error2ErrorInfoParser } = require ( "../utils" ) ;
1415
1516/**
1617 * @typedef {import("moleculer").ServiceBroker } ServiceBroker Moleculer Service Broker instance
@@ -58,6 +59,14 @@ class BaseAdapter {
5859
5960 /** @type {Boolean } Flag indicating the adapter's connection status */
6061 this . connected = false ;
62+
63+ /**
64+ * Function to convert Error to a plain object and gets error info ready to be placed in message headers
65+ *
66+ * @type {(error: Error) => Record<string, string> }
67+ */
68+ this . error2ErrorInfoParser =
69+ this . opts ?. deadLettering ?. error2ErrorInfoParser || error2ErrorInfoParser ;
6170 }
6271
6372 /**
Original file line number Diff line number Diff line change @@ -11,7 +11,6 @@ const _ = require("lodash");
1111const { MoleculerError, MoleculerRetryableError } = require ( "moleculer" ) . Errors ;
1212const C = require ( "../constants" ) ;
1313const { INVALID_MESSAGE_SERIALIZATION_ERROR_CODE } = require ( "../constants" ) ;
14- const { error2ErrorInfoParser } = require ( "../utils" ) ;
1514/** Name of the partition where an error occurred while processing the message */
1615const HEADER_ORIGINAL_PARTITION = "x-original-partition" ;
1716
@@ -70,9 +69,6 @@ class KafkaAdapter extends BaseAdapter {
7069 }
7170 } ) ;
7271
73- this . error2ErrorInfoParser =
74- this . opts ?. deadLettering ?. error2ErrorInfoParser || error2ErrorInfoParser ;
75-
7672 /** @type {KafkaConsumer } */
7773 this . client = null ;
7874
Original file line number Diff line number Diff line change @@ -82,9 +82,6 @@ class NatsAdapter extends BaseAdapter {
8282 }
8383 } ) ;
8484
85- this . error2ErrorInfoParser =
86- this . opts ?. deadLettering ?. error2ErrorInfoParser || error2ErrorInfoParser ;
87-
8885 // Adapted from: https://github.com/moleculerjs/moleculer/blob/3f7e712a8ce31087c7d333ad9dbaf63617c8497b/src/transporters/nats.js#L141-L143
8986 if ( this . opts . nats . url )
9087 this . opts . nats . connectionOptions . servers = this . opts . nats . url
Original file line number Diff line number Diff line change @@ -101,9 +101,8 @@ class RedisAdapter extends BaseAdapter {
101101 }
102102 } ) ;
103103
104+ /** @type {Number } Time-to-live in seconds for error info storage (only for Redis adapter) */
104105 this . errorInfoTTL = this . opts ?. deadLettering ?. errorInfoTTL || 24 * 3600 ; // 24 hours
105- this . error2ErrorInfoParser =
106- this . opts ?. deadLettering ?. error2ErrorInfoParser || error2ErrorInfoParser ;
107106
108107 /**
109108 * @type {Map<string,Cluster|Redis> }
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ const C = require("./constants");
2727 * @property {String } exchangeName Name of the dead-letter exchange (only for AMQP adapter)
2828 * @property {Object } exchangeOptions Options for the dead-letter exchange (only for AMQP adapter)
2929 * @property {Object } queueOptions Options for the dead-letter queue (only for AMQP adapter)
30- * @property {(error: Error) => Record<string, any > } [error2ErrorInfoParser] Function to convert Error object to a plain object
30+ * @property {(error: Error) => Record<string, string > } [error2ErrorInfoParser] Function to convert Error object to a plain object
3131 * @property {Number } errorInfoTTL Time-to-live in seconds for error info storage (only for Redis adapter)
3232 */
3333
You can’t perform that action at this time.
0 commit comments