Blake Schneider 5 anni fa
parent
commit
39c35982a9
1 ha cambiato i file con 9 aggiunte e 17 eliminazioni
  1. 9 17
      processes/report.js

+ 9 - 17
processes/report.js

@@ -4,20 +4,12 @@ const logger = require('../logger');
 const nantum = require('../modules/nantum');
 const { v4 } = require('uuid');
 
-// const reportSubscriptionParameters = {
-//   dataGranularitySeconds: 60,
-//   reportBackSeconds: 60,
-//   subscriptionDurationSeconds: 60 * 60,
-//   resubscribeDurationSeconds: 58 * 60,
-//   resubscribeAfterNoDataForSeconds: 90
-// };
-
 const reportSubscriptionParameters = {
   dataGranularitySeconds: 60,
   reportBackSeconds: 60,
-  subscriptionDurationSeconds: 4 * 60,
-  resubscribeDurationSeconds: 2 * 60,
-  resubscribeAfterNoDataForSeconds: 90,
+  subscriptionDurationSeconds: 60 * 60,
+  resubscribeDurationSeconds: 59 * 60,
+  resubscribeAfterNoDataForSeconds: 90
 };
 
 function getSecondsSince(property, reportMetadata) {
@@ -51,7 +43,7 @@ async function pollForReports(
 
       if (!reportMetadata.lastSentCreate) {
         // if we've never sent a subscription request, do it
-        // logger.info('sending create because we never have', reportMetadata.reportSpecifierId);
+        logger.info('sending create because we never have', reportMetadata.reportSpecifierId);
         sendCreate = true;
       } else {
         // have sent a create > 5s ago, not received a created
@@ -59,7 +51,7 @@ async function pollForReports(
           !reportMetadata.lastReceivedCreated &&
           getSecondsSince('lastSentCreate', reportMetadata) > 5
         ) {
-          // logger.info('no reply to creation request, send another', reportMetadata.reportSpecifierId);
+          logger.info('no reply to creation request, send another', reportMetadata.reportSpecifierId);
           sendCreate = true;
         }
       }
@@ -78,7 +70,7 @@ async function pollForReports(
           reportSubscriptionParameters.reportBackSeconds + 5
       ) {
         // if we haven't received any data but we've waited long enough for one data interval + 5 seconds
-        // logger.info('sending create because have not received data', reportMetadata.reportSpecifierId);
+        logger.info('sending create because have not received data', reportMetadata.reportSpecifierId);
         sendCreate = true;
       }
 
@@ -87,17 +79,17 @@ async function pollForReports(
         reportSubscriptionParameters.resubscribeDurationSeconds
       ) {
         // when we're close to the end of the subscription, trigger a resubscribe
-        // logger.info('sending create because close to end of subscription', reportMetadata.reportSpecifierId);
+        logger.info('sending create because close to end of subscription', reportMetadata.reportSpecifierId);
         sendCreate = true;
       }
 
       if (sendCreate) {
         const newReportRequestId = v4();
-        // track the last 5 registration ids
+        // track the last 10 registration ids
         reportMetadata.reportRequestIds = [
           newReportRequestId,
           ...reportMetadata.reportRequestIds,
-        ].slice(0, 5);
+        ].slice(0, 10);
         createRequests.push({
           reportRequestId: newReportRequestId,
           reportSpecifierId: reportMetadata.reportSpecifierId,