Skip to content

Commit

Permalink
feat: rename httpResponseTimeout to gracefulTerminationTimeout
Browse files Browse the repository at this point in the history
BREAKING CHANGE: renamed configuration to avoid ambiguity about the function of the configuration.
  • Loading branch information
gajus committed Jan 21, 2020
1 parent 57d4291 commit 4d1722d
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .README/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ import {
} from 'http-terminator';

/**
* @property httpResponseTimeout Number of milliseconds to allow for the active sockets to complete serving the response (default: 1000).
* @property gracefulTerminationTimeout Number of milliseconds to allow for the active sockets to complete serving the response (default: 5000).
* @property server Instance of http.Server.
*/
type HttpTerminatorConfigurationInputType = {|
+httpResponseTimeout?: number,
+gracefulTerminationTimeout?: number,
+server: Server,
|};

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ import {
} from 'http-terminator';

/**
* @property httpResponseTimeout Number of milliseconds to allow for the active sockets to complete serving the response (default: 1000).
* @property gracefulTerminationTimeout Number of milliseconds to allow for the active sockets to complete serving the response (default: 5000).
* @property server Instance of http.Server.
*/
type HttpTerminatorConfigurationInputType = {|
+httpResponseTimeout?: number,
+gracefulTerminationTimeout?: number,
+server: Server,
|};

Expand Down
4 changes: 2 additions & 2 deletions src/factories/createHttpTerminator.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const log = Logger.child({
});

const configurationDefaults = {
httpResponseTimeout: 1000,
gracefulTerminationTimeout: 1000,
};

export default (configurationInput: HttpTerminatorConfigurationInputType): HttpTerminatorType => {
Expand Down Expand Up @@ -119,7 +119,7 @@ export default (configurationInput: HttpTerminatorConfigurationInputType): HttpT
}

if (sockets.size) {
await delay(configuration.httpResponseTimeout);
await delay(configuration.gracefulTerminationTimeout);

for (const socket of sockets) {
destroySocket(socket);
Expand Down
4 changes: 2 additions & 2 deletions src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import type {
} from 'https';

/**
* @property httpResponseTimeout Number of milliseconds to allow for the active sockets to complete serving the response (default: 1000).
* @property gracefulTerminationTimeout Number of milliseconds to allow for the active sockets to complete serving the response (default: 5000).
* @property server Instance of http.Server.
*/
export type HttpTerminatorConfigurationInputType = {|
+httpResponseTimeout?: number,
+gracefulTerminationTimeout?: number,
+server: HttpServer | HttpsServer,
|};

Expand Down
10 changes: 5 additions & 5 deletions test/helpers/createTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default (createHttpServer: HttpServerFactoryType | HttpsServerFactoryType
t.false(httpServer.server.listening);
});

test('terminates hanging sockets after httpResponseTimeout', async (t) => {
test('terminates hanging sockets after gracefulTerminationTimeout', async (t) => {
const spy = sinon.spy();

const httpServer = await createHttpServer(() => {
Expand All @@ -46,7 +46,7 @@ export default (createHttpServer: HttpServerFactoryType | HttpsServerFactoryType
t.timeout(500);

const terminator = createHttpTerminator({
httpResponseTimeout: 150,
gracefulTerminationTimeout: 150,
server: httpServer.server,
});

Expand Down Expand Up @@ -91,7 +91,7 @@ export default (createHttpServer: HttpServerFactoryType | HttpsServerFactoryType
t.timeout(500);

const terminator = createHttpTerminator({
httpResponseTimeout: 150,
gracefulTerminationTimeout: 150,
server: httpServer.server,
});

Expand Down Expand Up @@ -130,7 +130,7 @@ export default (createHttpServer: HttpServerFactoryType | HttpsServerFactoryType
t.timeout(600);

const terminator = createHttpTerminator({
httpResponseTimeout: 150,
gracefulTerminationTimeout: 150,
server: httpServer.server,
});

Expand Down Expand Up @@ -190,7 +190,7 @@ export default (createHttpServer: HttpServerFactoryType | HttpsServerFactoryType
t.timeout(1000);

const terminator = createHttpTerminator({
httpResponseTimeout: 150,
gracefulTerminationTimeout: 150,
server: httpServer.server,
});

Expand Down
8 changes: 4 additions & 4 deletions test/http-server/factories/createHttpTerminator.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ test('terminates hanging sockets after httpResponseTimeout', async (t) => {
});

const terminator = createHttpTerminator({
httpResponseTimeout: 150,
gracefulTerminationTimeout: 150,
server: httpServer.server,
});

Expand Down Expand Up @@ -69,7 +69,7 @@ test('server stops accepting new connections after terminator.terminate() is cal
});

const terminator = createHttpTerminator({
httpResponseTimeout: 150,
gracefulTerminationTimeout: 150,
server: httpServer.server,
});

Expand Down Expand Up @@ -107,7 +107,7 @@ test('ongoing requests receive {connection: close} header', async (t) => {
});

const terminator = createHttpTerminator({
httpResponseTimeout: 150,
gracefulTerminationTimeout: 150,
server: httpServer.server,
});

Expand Down Expand Up @@ -158,7 +158,7 @@ test('ongoing requests receive {connection: close} header (new request reusing a
const httpServer = await createHttpServer(stub);

const terminator = createHttpTerminator({
httpResponseTimeout: 150,
gracefulTerminationTimeout: 150,
server: httpServer.server,
});

Expand Down

0 comments on commit 4d1722d

Please sign in to comment.