notification-processor 4.20.0 → 4.21.1

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/.node-version ADDED
@@ -0,0 +1 @@
1
+ 12.22.12
@@ -40,7 +40,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
40
40
 
41
41
  _classCallCheck(this, MonitoringCenterObserver);
42
42
 
43
- this.uploadTrackingFile = this.uploadTrackingFile.bind(this);
43
+ this.registerRecord = this.registerRecord.bind(this);
44
44
  this.sender = sender;
45
45
  this.clientId = clientId;
46
46
  this.app = app1;
@@ -57,25 +57,25 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
57
57
  var _this = this;
58
58
 
59
59
  observable.on("unsuccessful_non_retryable", function (payload) {
60
- return _this.uploadTrackingFile(payload, "unsuccessful_non_retryable");
60
+ return _this.registerRecord(payload, "unsuccessful");
61
61
  });
62
62
  observable.on("unsuccessful", function (payload) {
63
- return _this.uploadTrackingFile(payload, "unsuccessful");
63
+ return _this.registerRecord(payload, "unsuccessful");
64
64
  });
65
65
  observable.on("started", function (payload) {
66
- return _this.uploadTrackingFile(payload, "pending");
66
+ return _this.registerRecord(payload, "pending");
67
67
  });
68
68
  return observable.on("successful", function (payload) {
69
- return _this.uploadTrackingFile(payload, "successful");
69
+ return _this.registerRecord(payload, "successful");
70
70
  });
71
71
  }
72
72
  }, {
73
- key: "uploadTrackingFile",
74
- value: function uploadTrackingFile(payload, executionStatus) {
73
+ key: "registerRecord",
74
+ value: function registerRecord(payload, executionStatus) {
75
75
  var _this2 = this;
76
76
 
77
77
  return this._mapper(_.merge({ executionStatus: executionStatus }, payload)).tap(function (record) {
78
- return debug("Record to save in firehose %j", record);
78
+ return debug("Record to save in firehose %s %j", _this2.deliveryStream, record);
79
79
  }).then(function (record) {
80
80
  var __uploadToFirehose, uploadParams;
81
81
  if (_.isEmpty(record)) {
@@ -87,17 +87,17 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
87
87
  Data: JSON.stringify(record)
88
88
  }
89
89
  };
90
- debug("Uploading file " + record.event + "/" + record.id + " to firehose delivery stream " + uploadParams.DeliveryStreamName);
90
+ debug("Uploading record " + record.event + "/" + record.id + " to firehose delivery stream " + uploadParams.DeliveryStreamName);
91
91
  __uploadToFirehose = function __uploadToFirehose() {
92
92
  return _this2.uploadToFirehose(uploadParams);
93
93
  };
94
94
  return retry(__uploadToFirehose, {
95
95
  throw_original: true
96
96
  }).tap(function () {
97
- return debug("Uploaded file " + record.event + "/" + record.id + " to firehose delivery stream " + uploadParams.DeliveryStreamName);
97
+ return debug("Uploaded record " + record.event + "/" + record.id + " to firehose delivery stream " + uploadParams.DeliveryStreamName);
98
98
  }).catch(function (e) {
99
99
  // We'll do nothing with this error
100
- return debug("Error uploading file " + record.event + "/" + record.id + " to firehose delivery stream " + uploadParams.DeliveryStreamName + " %o", e);
100
+ return debug("Error uploading record " + record.event + "/" + record.id + " to firehose delivery stream " + uploadParams.DeliveryStreamName + " %o", e);
101
101
  });
102
102
  });
103
103
  }
package/lib/processor.js CHANGED
@@ -70,7 +70,7 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
70
70
  value: function process(context, raw) {
71
71
  var _this2 = this;
72
72
 
73
- var $promise, execute, id, notification;
73
+ var $promise, _isIgnoredError, execute, id, notification;
74
74
  boundMethodCheck(this, Processor);
75
75
  id = uuid();
76
76
  notification = this.source.newNotification({
@@ -94,9 +94,12 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
94
94
  });
95
95
  });
96
96
  };
97
+ _isIgnoredError = function _isIgnoredError(error) {
98
+ return error instanceof IgnoredError;
99
+ };
97
100
  execute().tap(function () {
98
101
  return _this2._emitEvent("successful", { context: context, id: id, notification: notification });
99
- }).catch(IgnoredError, function (error) {
102
+ }).catch(_isIgnoredError, function (error) {
100
103
  return _this2._emitEvent("successful", {
101
104
  context: context,
102
105
  id: id,
@@ -15,16 +15,20 @@
15
15
  notificationApiUrl = _ref.notificationApiUrl,
16
16
  maxRetries = _ref.maxRetries,
17
17
  _ref$nonRetryable = _ref.nonRetryable,
18
- nonRetryable = _ref$nonRetryable === undefined ? [400] : _ref$nonRetryable;
18
+ nonRetryable = _ref$nonRetryable === undefined ? [400] : _ref$nonRetryable,
19
+ _ref$silentErrors = _ref.silentErrors,
20
+ silentErrors = _ref$silentErrors === undefined ? [] : _ref$silentErrors;
19
21
 
20
22
  var jobProcesor;
21
23
  jobProcesor = new JobProcessor({
22
24
  processor: RequestAsyncProcessor({
23
25
  apiUrl: apiUrl,
24
- fullResponse: true
26
+ fullResponse: true,
27
+ silentErrors: silentErrors
25
28
  }),
26
29
  maxRetries: maxRetries,
27
30
  nonRetryable: nonRetryable,
31
+ silentErrors: silentErrors,
28
32
  notificationApiUrl: notificationApiUrl
29
33
  });
30
34
  return function (it, context, executionId) {
@@ -56,6 +56,7 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
56
56
  _this.notificationApiUrl = args.notificationApiUrl;
57
57
  _this.notificationApiAsyncUrl = args.notificationApiAsyncUrl;
58
58
  _this.nonRetryable = args.nonRetryable;
59
+ _this.silentErrors = args.silentErrors;
59
60
  return _this;
60
61
  }
61
62
 
@@ -6,7 +6,11 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
6
6
 
7
7
  // Generated by CoffeeScript 2.7.0
8
8
  (function () {
9
- var MaxRetriesProcessor;
9
+ var IgnoredError, MaxRetriesProcessor, Promise;
10
+
11
+ Promise = require("bluebird");
12
+
13
+ IgnoredError = require("../exceptions/ignored.error");
10
14
 
11
15
  module.exports = MaxRetriesProcessor = function () {
12
16
  function MaxRetriesProcessor(_ref) {
@@ -16,6 +20,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
16
20
 
17
21
  _classCallCheck(this, MaxRetriesProcessor);
18
22
 
23
+ this._onIgnoredError_ = this._onIgnoredError_.bind(this);
19
24
  this.processor = processor;
20
25
  this.maxRetries = maxRetries;
21
26
  }
@@ -28,6 +33,9 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
28
33
  return this.processor(notification, context, executionId).tap(function (it) {
29
34
  return _this._onSuccess_(notification, it);
30
35
  }).catch(function (err) {
36
+ if (_this._isIgnoredError_(err)) {
37
+ return _this._onIgnoredError_(notification, err);
38
+ }
31
39
  if (_this._shouldRetry_(notification, err)) {
32
40
  throw _this._sanitizeError_(err);
33
41
  }
@@ -57,6 +65,22 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
57
65
  value: function _onMaxRetryExceeded_(notification, err) {
58
66
  throw new Error("subclass responsability");
59
67
  }
68
+ }, {
69
+ key: "_onIgnoredError_",
70
+ value: function _onIgnoredError_(notification, err) {
71
+ var _this2 = this;
72
+
73
+ return Promise.try(function () {
74
+ return _this2._onSuccess_(notification, err);
75
+ }).tap(function () {
76
+ throw err;
77
+ });
78
+ }
79
+ }, {
80
+ key: "_isIgnoredError_",
81
+ value: function _isIgnoredError_(err) {
82
+ return err instanceof IgnoredError;
83
+ }
60
84
  }]);
61
85
 
62
86
  return MaxRetriesProcessor;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notification-processor",
3
- "version": "4.20.0",
3
+ "version": "4.21.1",
4
4
  "description": "notification-processor",
5
5
  "main": "index.js",
6
6
  "scripts": {