This is an automated email from the ASF dual-hosted git repository.

csantanapr pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/incubator-openwhisk-package-alarms.git


The following commit(s) were added to refs/heads/master by this push:
     new 85434e1  Avoid that trigger is fired too often if Request to OpenWhisk 
is too slow. (#83)
85434e1 is described below

commit 85434e184821370107d0445a30cb3ae060b7f061
Author: Christian Bickel <git...@cbickel.de>
AuthorDate: Wed Aug 9 16:16:47 2017 +0200

    Avoid that trigger is fired too often if Request to OpenWhisk is too slow. 
(#83)
---
 provider/lib/utils.js | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/provider/lib/utils.js b/provider/lib/utils.js
index 847b4cf..02b3718 100644
--- a/provider/lib/utils.js
+++ b/provider/lib/utils.js
@@ -98,6 +98,11 @@ module.exports = function(
 
         return new Promise(function(resolve, reject) {
 
+            // only manage trigger fires if they are not infinite
+            if (dataTrigger.maxTriggers !== -1) {
+                dataTrigger.triggersLeft--;
+            }
+
             request({
                 method: 'post',
                 uri: uri,
@@ -112,6 +117,10 @@ module.exports = function(
                     logger.info(method, triggerIdentifier, 'http post request, 
STATUS:', response ? response.statusCode : response);
 
                     if (error || response.statusCode >= 400) {
+                        // only manage trigger fires if they are not infinite
+                        if (dataTrigger.maxTriggers !== -1) {
+                            dataTrigger.triggersLeft++;
+                        }
                         logger.error(method, 'there was an error invoking', 
triggerIdentifier, response ? response.statusCode : error);
                         if (!error && 
utils.shouldDisableTrigger(response.statusCode)) {
                             //disable trigger
@@ -136,10 +145,6 @@ module.exports = function(
                             }
                         }
                     } else {
-                        // only manage trigger fires if they are not infinite
-                        if (dataTrigger.maxTriggers !== -1) {
-                            dataTrigger.triggersLeft--;
-                        }
                         logger.info(method, 'fired', triggerIdentifier, 
dataTrigger.triggersLeft, 'triggers left');
                         resolve(triggerIdentifier);
                     }

-- 
To stop receiving notification emails like this one, please contact
['"commits@openwhisk.apache.org" <commits@openwhisk.apache.org>'].

Reply via email to