From 78f67d4a7681a1e652f57acdf0261f11b910515f Mon Sep 17 00:00:00 2001 From: Juan Tejada Date: Tue, 14 Feb 2017 18:28:07 -0800 Subject: [PATCH] [cloud-api] KEEP Timeout streaming API connections every 15 minutes This reverts commit a1b997f350d493d477744e9ce3f06fcb0a9130b2. This is actually working correctly to reduce REDIS connections --- packages/isomorphic-core/src/delta-stream-builder.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/isomorphic-core/src/delta-stream-builder.js b/packages/isomorphic-core/src/delta-stream-builder.js index b89cf1b7e..f346abdd5 100644 --- a/packages/isomorphic-core/src/delta-stream-builder.js +++ b/packages/isomorphic-core/src/delta-stream-builder.js @@ -1,6 +1,8 @@ const _ = require('underscore'); const Rx = require('rx') const stream = require('stream'); +const DELTA_CONNECTION_TIMEOUT_MS = 15 * 60000; +const OBSERVABLE_TIMEOUT_MS = DELTA_CONNECTION_TIMEOUT_MS - (1 * 60000); /** * A Transaction references objects that changed. This finds and inflates @@ -61,6 +63,7 @@ function transactionsSinceCursor(db, cursor, accountId) { } module.exports = { + DELTA_CONNECTION_TIMEOUT_MS: DELTA_CONNECTION_TIMEOUT_MS, buildAPIStream(request, {databasePromise, cursor, accountId, deltasSource}) { return databasePromise.then((db) => { const source = Rx.Observable.merge( @@ -69,7 +72,7 @@ module.exports = { deltasSource.flatMap((t) => stringifyTransactions(db, accountId, [t], "new")), Rx.Observable.interval(1000).map(() => "\n") - ) + ).timeout(OBSERVABLE_TIMEOUT_MS); const outputStream = stream.Readable(); outputStream._read = () => { return };