Skip to content

Commit

Permalink
chore: Pass keepAlive and noDelay options during createConnection
Browse files Browse the repository at this point in the history
  • Loading branch information
marcbachmann committed Mar 30, 2022
1 parent d63e70b commit f39acf4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
4 changes: 0 additions & 4 deletions lib/Redis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,6 @@ class Redis extends Commander {
stream.once("close", eventHandler.closeHandler(_this));
}

if (options.noDelay) {
stream.setNoDelay(true);
}

const connectionReadyHandler = function () {
_this.removeListener("close", connectionCloseHandler);
resolve();
Expand Down
12 changes: 12 additions & 0 deletions lib/connectors/StandaloneConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export type StandaloneConnectionOptions = (Partial<TcpNetConnectOpts> &
Partial<IpcNetConnectOpts>) & {
disconnectTimeout?: number;
tls?: ConnectionOptions;
noDelay?: boolean;
keepAlive?: number;
};

export default class StandaloneConnector extends AbstractConnector {
Expand Down Expand Up @@ -41,6 +43,16 @@ export default class StandaloneConnector extends AbstractConnector {
Object.assign(connectionOptions, options.tls);
}

if (options.noDelay === true) {
connectionOptions.noDelay = true;
}

if (typeof options.keepAlive === 'number') {
connectionOptions.keepAlive = true;
connectionOptions.keepAliveInitialDelay = options.keepAlive;
}


// TODO:
// We use native Promise here since other Promise
// implementation may use different schedulers that
Expand Down
4 changes: 0 additions & 4 deletions lib/redis/event_handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ export function connectHandler(self) {

self.resetCommandQueue();

if (typeof self.options.keepAlive === "number") {
self.stream.setKeepAlive(true, self.options.keepAlive);
}

// AUTH command should be processed before any other commands
let flushed = false;
const { connectionEpoch } = self;
Expand Down

0 comments on commit f39acf4

Please sign in to comment.