New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cqrs-saga

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cqrs-saga - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

projectFilesBackup/.idea/workspace.xml

54

lib/definitions/saga.js

@@ -159,2 +159,26 @@ 'use strict';

function retry (retryIn, callback) {
if (!callback && _.isFunction(retryIn)) {
callback = retryIn;
retryIn = 0;
}
if (_.isNumber(retryIn)) {
retryIn = randomBetween(0, retryIn);
}
if (_.isObject(retryIn) && _.isNumber(retryIn.from) && _.isNumber(retryIn.to)) {
retryIn = randomBetween(retryIn.from, retryIn.to);
}
if (!_.isNumber(retryIn) || retryIn === 0) {
retryIn = randomBetween(0, self.options ? self.options.retryOnConcurrencyTimeout : 800);
}
debug('retry in ' + retryIn + 'ms');
setTimeout(function() {
self.handle(evt, callback);
}, retryIn);
}
var self = this;

@@ -232,11 +256,6 @@ async.waterfall([

if (err instanceof ConcurrencyError) {
var waitTime = self.options ? self.options.retryOnConcurrencyTimeout : 800;
var retryIn = randomBetween(0, waitTime);
debug('retry in ' + retryIn + 'ms');
setTimeout(function() {
self.handle(evt, clb);
}, retryIn);
} else {
clb(err);
retry(clb);
return;
}
clb(err);
});

@@ -289,3 +308,20 @@ }

function (sagaModel, callb) {
self.sagaFn(self.getPayload(evt), sagaModel, function (err) {
var sagaThis = {
retry: function () {
if (arguments.length === 0) {
return retry(callb);
}
if (arguments.length === 1) {
if (!_.isFunction(arguments[0])) {
return retry(arguments[0], callb);
}
return retry(arguments[0]);
}
retry(arguments[0], arguments[1]);
}
};
self.sagaFn.call(sagaThis, self.getPayload(evt), sagaModel, function (err) {
if (err) {

@@ -292,0 +328,0 @@ return callb(err);

2

package.json
{
"author": "adrai",
"name": "cqrs-saga",
"version": "1.3.0",
"version": "1.4.0",
"private": false,

@@ -6,0 +6,0 @@ "main": "index.js",

@@ -363,3 +363,12 @@ # Introduction

}, function (evt, saga, callback) {
// if you have multiple concurrent events that targets the same saga, you can catch it like this:
if (saga.actionOnCommit === 'create') {
return this.retry(callback);
// or
//return this.retry(100, callback); // retries to handle again in 0-100ms
// or
//return this.retry({ from: 500, to: 8000 }, callback); // retries to handle again in 500-8000ms
}
saga.set('orderId', evt.aggregate.id);

@@ -366,0 +375,0 @@ saga.set('totalCosts', evt.payload.totalCosts);

@@ -0,1 +1,4 @@

## [v1.4.0](https://github.com/adrai/node-cqrs-saga/compare/v1.3.0...v1.4.0)
- add retry mechanism for saga
## [v1.3.0](https://github.com/adrai/node-cqrs-saga/compare/v1.2.9...v1.3.0)

@@ -2,0 +5,0 @@ - fix revisionGuard when handling duplicate events at the same time

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc