mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-24 16:14:01 +08:00
[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:
parent
a1b997f350
commit
78f67d4a76
1 changed files with 4 additions and 1 deletions
|
@ -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 };
|
||||
|
|
Loading…
Reference in a new issue