Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

historical-deadletter-processor

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

historical-deadletter-processor - npm Package Compare versions

Comparing version 1.1.6 to 1.2.0

130

lib/historical.deadletter.processor.js
(function() {
var HighlandPagination, HistoricalDeadletterProcessor, Promise, Query, _, createClient, highland, moment, parseAccountString, ref,
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
var HighlandPagination, HistoricalDeadletterProcessor, Promise, Query, _, createClient, highland, moment, parseAccountString;

@@ -11,3 +10,3 @@ _ = require("lodash");

ref = require("azure-table-node"), parseAccountString = ref.parseAccountString, createClient = ref.createClient, Query = ref.Query;
({parseAccountString, createClient, Query} = require("azure-table-node"));

@@ -18,17 +17,19 @@ HighlandPagination = require("highland-pagination");

module.exports = HistoricalDeadletterProcessor = (function() {
function HistoricalDeadletterProcessor(processor, arg, concurrency, logger, daysRetrying) {
var connection;
this.processor = processor;
connection = arg.connection, this.tableName = arg.tableName, this.partitionKey = arg.partitionKey;
this.concurrency = concurrency != null ? concurrency : {
require("highland-concurrent-flatmap");
module.exports = HistoricalDeadletterProcessor = class HistoricalDeadletterProcessor {
constructor(processor, {connection, tableName, partitionKey}, concurrency = {
callsToApi: 20,
callsToAzure: 50
};
this.logger = logger != null ? logger : console;
this.daysRetrying = daysRetrying != null ? daysRetrying : 1;
this._remove = bind(this._remove, this);
this._doProcess = bind(this._doProcess, this);
this._retrieveMessages = bind(this._retrieveMessages, this);
this.run = bind(this.run, this);
}, logger = console, daysRetrying = 1) {
this.run = this.run.bind(this);
this._retrieveMessages = this._retrieveMessages.bind(this);
this._doProcess = this._doProcess.bind(this);
this._remove = this._remove.bind(this);
this.processor = processor;
this.tableName = tableName;
this.partitionKey = partitionKey;
this.concurrency = concurrency;
this.logger = logger;
this.daysRetrying = daysRetrying;
if (_.isString(connection)) {

@@ -42,71 +43,52 @@ connection = parseAccountString(connection);

HistoricalDeadletterProcessor.prototype.run = function() {
run() {
return new HighlandPagination(this._retrieveMessages).stream().map(function(row) {
return _.update(row, "notification", JSON.parse);
}).map((function(_this) {
return function(row) {
var RowKey;
RowKey = row.RowKey;
return _this._doProcess(row).tap(function() {
return _this.logger.info("Process successful " + RowKey);
}).map(function() {
return row;
}).errors(function() {
return _this.logger.warn("Still fails " + RowKey);
});
};
})(this)).parallel(this.concurrency.callsToApi).map((function(_this) {
return function(row) {
return _this._remove(row);
};
})(this)).parallel(this.concurrency.callsToAzure).collect().toPromise(Promise);
};
}).concurrentFlatMap(this.concurrency.callsToApi, (row) => {
var RowKey;
({RowKey} = row);
return this._doProcess(row).tap(() => {
return this.logger.info(`Process successful ${RowKey}`);
}).map(function() {
return row;
}).errors(() => {
return this.logger.warn(`Still fails ${RowKey}`);
});
}).concurrentFlatMap(this.concurrency.callsToAzure, (row) => {
return this._remove(row);
}).reduce1(highland.add).toPromise(Promise);
}
HistoricalDeadletterProcessor.prototype._retrieveMessages = function(continuation) {
_retrieveMessages(continuation) {
var query;
query = Query.create().where("PartitionKey", "==", "" + this.partitionKey).and("Timestamp", ">", moment().subtract(this.daysRetrying, 'days').toDate());
query = Query.create().where("PartitionKey", "==", `${this.partitionKey}`).and("Timestamp", ">", moment().subtract(this.daysRetrying, 'days').toDate());
return this.client.queryEntitiesAsync(this.tableName, {
query: query,
query,
limitTo: 20,
continuation: continuation
}).spread((function(_this) {
return function(items, nextToken) {
return {
items: items,
nextToken: nextToken
};
};
})(this));
};
continuation
}).spread((items, nextToken) => {
return {items, nextToken};
});
}
HistoricalDeadletterProcessor.prototype._doProcess = function(row) {
return highland((function(_this) {
return function(push, next) {
var __done;
__done = function(err) {
push(err, null);
return push(null, highland.nil);
};
return _this.processor({
done: __done,
log: _this.logger
}, row);
_doProcess(row) {
return highland((push, next) => {
var __done;
__done = function(err) {
push(err, null);
return push(null, highland.nil);
};
})(this));
};
return this.processor({
done: __done,
log: this.logger
}, row);
});
}
HistoricalDeadletterProcessor.prototype._remove = function(arg) {
var PartitionKey, RowKey, __etag;
PartitionKey = arg.PartitionKey, RowKey = arg.RowKey, __etag = arg.__etag;
return highland(this.client.deleteEntityAsync(this.tableName, {
PartitionKey: PartitionKey,
RowKey: RowKey,
__etag: __etag
}));
};
_remove({PartitionKey, RowKey, __etag}) {
return highland(this.client.deleteEntityAsync(this.tableName, {PartitionKey, RowKey, __etag}));
}
return HistoricalDeadletterProcessor;
};
})();
}).call(this);
{
"name": "historical-deadletter-processor",
"version": "1.1.6",
"version": "1.2.0",
"description": "historical-deadletter-processor",

@@ -8,3 +8,3 @@ "main": "index.js",

"test": "grunt test",
"prepublish": "grunt build"
"prepare": "grunt build"
},

@@ -17,15 +17,18 @@ "repository": {

"azure-table-node": "^1.5.0",
"lodash": "4.17.10",
"highland-concurrent-flatmap": "0.0.1",
"lodash": "^4.17.10",
"moment": "^2.0.0"
},
"devDependencies": {
"bluebird": "3.5.1",
"coffee-script": "1.12.7",
"grunt": "1.0.3",
"grunt-bump": "0.8.0",
"grunt-contrib-clean": "1.1.0",
"grunt-contrib-coffee": "2.0.0",
"grunt-mocha-test": "0.13.3",
"mocha": "5.2.0",
"should": "13.2.1"
"bluebird": "^3.5.1",
"coffeescript": "^1.12.7",
"grunt": "^1.0.3",
"grunt-bump": "^0.8.0",
"grunt-contrib-clean": "^1.1.0",
"grunt-contrib-coffee": "^2.0.0",
"grunt-mocha-test": "^0.13.3",
"highland": "^2.13.0",
"highland-pagination": "^0.1.2",
"mocha": "^5.2.0",
"should": "^13.2.1"
},

@@ -32,0 +35,0 @@ "peerDependencies": {

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