From cc89aac5f7d5443e0be9d037f067391ab144244e Mon Sep 17 00:00:00 2001 From: James M Snell Date: Tue, 7 Jul 2020 13:42:25 -0700 Subject: [PATCH] quic: refactor/improve error handling for busy event Also, change setServerBusy into a setter PR-URL: https://github.com/nodejs/node/pull/34247 Reviewed-By: Anna Henningsen --- doc/api/quic.md | 33 +++++++++---------- lib/internal/quic/core.js | 17 +++++++--- ...test-quic-server-busy-event-error-async.js | 32 ++++++++++++++++++ .../test-quic-server-busy-event-error.js | 32 ++++++++++++++++++ 4 files changed, 93 insertions(+), 21 deletions(-) create mode 100644 test/parallel/test-quic-server-busy-event-error-async.js create mode 100644 test/parallel/test-quic-server-busy-event-error.js diff --git a/doc/api/quic.md b/doc/api/quic.md index 6b0f9ae41bb12e..a847ac621aa268 100644 --- a/doc/api/quic.md +++ b/doc/api/quic.md @@ -1330,8 +1330,8 @@ added: REPLACEME --> Emitted when the server busy state has been toggled using -`quicSocket.setServerBusy()`. The callback is invoked with a single -boolean argument indicating `true` if busy status is enabled, +`quicSocket.serverBusy = true | false`. The callback is invoked with a +single boolean argument indicating `true` if busy status is enabled, `false` otherwise. This event is strictly informational. ```js @@ -1346,8 +1346,8 @@ socket.on('busy', (busy) => { console.log('Server is not busy'); }); -socket.setServerBusy(true); -socket.setServerBusy(false); +socket.serverBusy = true; +socket.serverBusy = false; ``` This `'busy'` event may be emitted multiple times. @@ -1874,6 +1874,18 @@ Set to `true` if the socket is not yet bound to the local UDP port. added: REPLACEME --> +#### quicsocket.serverBusy + + +* Type: {boolean} When `true`, the `QuicSocket` will reject new connections. + +Setting `quicsocket.serverBusy` to `true` will tell the `QuicSocket` +to reject all new incoming connection requests using the `SERVER_BUSY` QUIC +error code. To begin receiving connections again, disable busy mode by setting +`quicsocket.serverBusy = false`. + #### quicsocket.serverBusyCount - -* `on` {boolean} When `true`, the `QuicSocket` will reject new connections. - **Defaults**: `true`. - -Calling `setServerBusy()` or `setServerBusy(true)` will tell the `QuicSocket` -to reject all new incoming connection requests using the `SERVER_BUSY` QUIC -error code. To begin receiving connections again, disable busy mode by calling -`setServerBusy(false)`. - #### quicsocket.statelessResetCount