[cloud-api] KEEP Timeout streaming API connections every 15 minutes

This reverts commit a1b997f350.
This is actually working correctly to reduce REDIS connections
This commit is contained in:
Juan Tejada 2017-02-14 18:28:07 -08:00
parent a1b997f350
commit 78f67d4a76

View file

@ -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 };