@zdavison/matador 4.1.0 → 4.2.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.cjs +48 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/pipeline/pipeline.d.ts.map +1 -1
- package/dist/pipeline/pipeline.js +5 -1
- package/dist/retry/policy.d.ts +2 -0
- package/dist/retry/policy.d.ts.map +1 -1
- package/dist/retry/standard-policy.d.ts +16 -3
- package/dist/retry/standard-policy.d.ts.map +1 -1
- package/dist/retry/standard-policy.js +36 -9
- package/package.json +1 -1
- package/dist/checkpoint/context.test.d.ts +0 -2
- package/dist/checkpoint/context.test.d.ts.map +0 -1
- package/dist/checkpoint/context.test.js +0 -428
- package/dist/checkpoint/stores/stores.test.d.ts +0 -2
- package/dist/checkpoint/stores/stores.test.d.ts.map +0 -1
- package/dist/checkpoint/stores/stores.test.js +0 -146
- package/dist/codec/rabbitmq-codec.test.d.ts +0 -2
- package/dist/codec/rabbitmq-codec.test.d.ts.map +0 -1
- package/dist/codec/rabbitmq-codec.test.js +0 -428
- package/dist/core/fanout.test.d.ts +0 -2
- package/dist/core/fanout.test.d.ts.map +0 -1
- package/dist/core/fanout.test.js +0 -1970
- package/dist/core/matador.test.d.ts +0 -2
- package/dist/core/matador.test.d.ts.map +0 -1
- package/dist/core/matador.test.js +0 -906
- package/dist/core/shutdown.test.d.ts +0 -2
- package/dist/core/shutdown.test.d.ts.map +0 -1
- package/dist/core/shutdown.test.js +0 -599
- package/dist/errors/retry-errors.test.d.ts +0 -2
- package/dist/errors/retry-errors.test.d.ts.map +0 -1
- package/dist/errors/retry-errors.test.js +0 -136
- package/dist/pipeline/pipeline.test.d.ts +0 -2
- package/dist/pipeline/pipeline.test.d.ts.map +0 -1
- package/dist/pipeline/pipeline.test.js +0 -1247
- package/dist/retry/standard-policy.test.d.ts +0 -2
- package/dist/retry/standard-policy.test.d.ts.map +0 -1
- package/dist/retry/standard-policy.test.js +0 -261
- package/dist/schema/registry.test.d.ts +0 -2
- package/dist/schema/registry.test.d.ts.map +0 -1
- package/dist/schema/registry.test.js +0 -278
- package/dist/schema/types.test.d.ts +0 -2
- package/dist/schema/types.test.d.ts.map +0 -1
- package/dist/schema/types.test.js +0 -246
- package/dist/topology/builder.test.d.ts +0 -2
- package/dist/topology/builder.test.d.ts.map +0 -1
- package/dist/topology/builder.test.js +0 -554
- package/dist/transport/local/local-transport.test.d.ts +0 -2
- package/dist/transport/local/local-transport.test.d.ts.map +0 -1
- package/dist/transport/local/local-transport.test.js +0 -232
- package/dist/transport/multi/multi-transport.test.d.ts +0 -2
- package/dist/transport/multi/multi-transport.test.d.ts.map +0 -1
- package/dist/transport/multi/multi-transport.test.js +0 -322
- package/dist/transport/rabbitmq/rabbitmq-transport-reconnection.test.d.ts +0 -2
- package/dist/transport/rabbitmq/rabbitmq-transport-reconnection.test.d.ts.map +0 -1
- package/dist/transport/rabbitmq/rabbitmq-transport-reconnection.test.js +0 -149
- package/dist/transport/rabbitmq/rabbitmq-transport.test.d.ts +0 -2
- package/dist/transport/rabbitmq/rabbitmq-transport.test.d.ts.map +0 -1
- package/dist/transport/rabbitmq/rabbitmq-transport.test.js +0 -258
- package/dist/types/event.test.d.ts +0 -2
- package/dist/types/event.test.d.ts.map +0 -1
- package/dist/types/event.test.js +0 -130
package/dist/index.cjs
CHANGED
|
@@ -2005,7 +2005,11 @@ var ProcessingPipeline = class {
|
|
|
2005
2005
|
* @returns A `ProcessResult` indicating if we should continue with processing the message, or fail it preemptively
|
|
2006
2006
|
*/
|
|
2007
2007
|
async handleShouldProcess(envelope, subscriberDef, isResumable, receipt, startTime) {
|
|
2008
|
-
const decision = this.retryPolicy.shouldProcess({
|
|
2008
|
+
const decision = this.retryPolicy.shouldProcess({
|
|
2009
|
+
envelope,
|
|
2010
|
+
subscriber: subscriberDef,
|
|
2011
|
+
receipt
|
|
2012
|
+
});
|
|
2009
2013
|
if (decision.action === "process") {
|
|
2010
2014
|
return {
|
|
2011
2015
|
success: true,
|
|
@@ -2147,13 +2151,16 @@ var StandardRetryPolicy = class {
|
|
|
2147
2151
|
this.config = { ...defaultRetryConfig, ...config };
|
|
2148
2152
|
}
|
|
2149
2153
|
/**
|
|
2150
|
-
* Check if the message should be dead-lettered before the subscriber callback is invoked
|
|
2154
|
+
* Check if the message should be dead-lettered before the subscriber callback is invoked.
|
|
2155
|
+
* This is needed when a subscriber crashes and the `shouldRetry` policy is never executed.
|
|
2151
2156
|
*
|
|
2152
2157
|
* Uses the same delivery-count threshold as `shouldRetry` poison check, so an
|
|
2153
2158
|
* already-poisoned message is dead-lettered without ever running the callback again.
|
|
2154
2159
|
*
|
|
2160
|
+
* Checks the subscriber idempotency setting to prevent processing when a previous attempt crashed.
|
|
2161
|
+
*
|
|
2155
2162
|
* @param context - The shouldProcess context.
|
|
2156
|
-
* @returns A 'process' decision if
|
|
2163
|
+
* @returns A 'process' decision if subscriber processing should be attempted; a dead-letter decision otherwise.
|
|
2157
2164
|
*/
|
|
2158
2165
|
shouldProcess(context) {
|
|
2159
2166
|
const poisonError = this.checkPoisoned(context.envelope, context.receipt);
|
|
@@ -2164,6 +2171,18 @@ var StandardRetryPolicy = class {
|
|
|
2164
2171
|
reason: poisonError.message
|
|
2165
2172
|
};
|
|
2166
2173
|
}
|
|
2174
|
+
const idempotencyError = this.checkIdempotency(
|
|
2175
|
+
context.envelope,
|
|
2176
|
+
context.receipt,
|
|
2177
|
+
context.subscriber
|
|
2178
|
+
);
|
|
2179
|
+
if (idempotencyError) {
|
|
2180
|
+
return {
|
|
2181
|
+
action: "dead-letter",
|
|
2182
|
+
queue: "undeliverable",
|
|
2183
|
+
reason: idempotencyError.message
|
|
2184
|
+
};
|
|
2185
|
+
}
|
|
2167
2186
|
return { action: "process" };
|
|
2168
2187
|
}
|
|
2169
2188
|
shouldRetry(context) {
|
|
@@ -2211,15 +2230,17 @@ var StandardRetryPolicy = class {
|
|
|
2211
2230
|
reason: `max attempts exceeded (${this.config.maxAttempts})`
|
|
2212
2231
|
};
|
|
2213
2232
|
}
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2233
|
+
const idempotencyError = this.checkIdempotency(
|
|
2234
|
+
envelope,
|
|
2235
|
+
receipt,
|
|
2236
|
+
subscriber,
|
|
2237
|
+
error
|
|
2238
|
+
);
|
|
2239
|
+
if (idempotencyError) {
|
|
2219
2240
|
return {
|
|
2220
2241
|
action: "dead-letter",
|
|
2221
2242
|
queue: "undeliverable",
|
|
2222
|
-
reason:
|
|
2243
|
+
reason: idempotencyError.message
|
|
2223
2244
|
};
|
|
2224
2245
|
}
|
|
2225
2246
|
return {
|
|
@@ -2249,6 +2270,24 @@ var StandardRetryPolicy = class {
|
|
|
2249
2270
|
}
|
|
2250
2271
|
return null;
|
|
2251
2272
|
}
|
|
2273
|
+
/**
|
|
2274
|
+
* Checks whether the subscriber allows retries based on its idempotency setting
|
|
2275
|
+
*
|
|
2276
|
+
* @param envelope - The message envelope.
|
|
2277
|
+
* @param receipt - The message receipt.
|
|
2278
|
+
* @param subscriber - The subscriber definition
|
|
2279
|
+
* @param error - The processing error, if it exists
|
|
2280
|
+
* @returns A IdempotentMessageCannotRetryError if the message is poisoned; null otherwise
|
|
2281
|
+
*/
|
|
2282
|
+
checkIdempotency(envelope, receipt, subscriber, error) {
|
|
2283
|
+
if ((error || receipt.redelivered) && (subscriber.idempotent === "no" || subscriber.idempotent === "unknown")) {
|
|
2284
|
+
return new IdempotentMessageCannotRetryError(
|
|
2285
|
+
envelope.id,
|
|
2286
|
+
subscriber.name
|
|
2287
|
+
);
|
|
2288
|
+
}
|
|
2289
|
+
return null;
|
|
2290
|
+
}
|
|
2252
2291
|
};
|
|
2253
2292
|
|
|
2254
2293
|
// src/schema/types.ts
|