Rename connection shutdown to prepare disconnect

Rename the shutdownConnection request to prepareDisconnect to better
reflect its actual purpose.
This commit is contained in:
Hornwitser committed 2020-04-09 16:17:38 +02:00
1 parent e7d1039942
commit 47ea8f5477
7 files changed
+18 -17

No files matched your search

+1 -1
View File
@@ -353,7 +353,7 @@ class Control extends link.Link {
} }
async shutdown() { async shutdown() {
await link.messages.shutdownConnection.send(this); await link.messages.prepareDisconnect.send(this);
this.connector.close(1001, "Control Quit") this.connector.close(1001, "Control Quit")
await events.once(this.connector, "close"); await events.once(this.connector, "close");
} }
+10 -9
View File
@@ -253,28 +253,29 @@ requests and their contents.
- error - string - Human readable text message describing the error. - error - string - Human readable text message describing the error.
Graceful shutdown Graceful Disconnect
----------------- -------------------
To ensure no data is lost when closing the link it's important to To ensure no data is lost when closing the link it's important to
send connection shutdown request and wait for it to complete before send a prepare disconnect request and wait for it to complete before
closing the WebSocket. Either party of the link can send this request closing the WebSocket. Either party of the link can send this request
and the party sending the request should be the one that initates the and the party sending the request should be the one that initates the
close of the WebSocket. close of the WebSocket.
### `connection_shutdown_request` ### `prepare_disconnect_request`
Request graceful shutdown of the connection. The receiving party should Request graceful disconnect of the connection. The receiving party should
stop tasks that send events and requests over the link and wait for stop tasks that send events and requests over the link and wait for
pending requests it has over the link to complete, but it should not pending requests it has over the link to complete, but it should not
stop responding to requests sent to it. Only after this process is done stop responding to requests sent to it. Only after this process is done
should the response be sent. should the response be sent.
### `connection_shutdown_response` ### `prepare_disconnect_response`
Signals the shutdown is complete and that the connection can be closed. Signals the preparation for disconnect is complete and that the
The party that initiatied the shutdown request may still send other connection can be closed. The party that initiatied the prepare
requests/events over the link to finish its part of the shutdown. disconnect request may still send other requests/events over the link to
finish its part of the disconnection proceedure.
If the error response variant is received it should be logged if If the error response variant is received it should be logged if
possible and treated as a success. possible and treated as a success.
+2 -2
View File
@@ -208,14 +208,14 @@ class Link {
async pingRequestHandler() { } async pingRequestHandler() { }
/** /**
* Prepare connection for close * Prepare connection for disconnect
* *
* Waits for all pending requests on the connection to resolve. * Waits for all pending requests on the connection to resolve.
* Sub-classes should implement this handler with code that prevents * Sub-classes should implement this handler with code that prevents
* additional requests to be sent out before calling the super class * additional requests to be sent out before calling the super class
* method. * method.
*/ */
async shutdownConnectionRequestHandler() { async prepareDisconnectRequestHandler() {
let promises = []; let promises = [];
for (let waiterType of this._waiters.values()) { for (let waiterType of this._waiters.values()) {
for (let waiter of waiterType) { for (let waiter of waiterType) {
+2 -2
View File
@@ -185,8 +185,8 @@ let messages = {}
// Connection requests // Connection requests
let wsLinks = ["master-control", "control-master", "master-slave", "slave-master"]; let wsLinks = ["master-control", "control-master", "master-slave", "slave-master"];
messages.shutdownConnection = new Request({ messages.prepareDisconnect = new Request({
type: "shutdown_connection", type: "prepare_disconnect",
links: wsLinks, links: wsLinks,
}); });
+1 -1
View File
@@ -381,7 +381,7 @@ class BaseConnection extends link.Link {
} }
async shutdown(code, reason) { async shutdown(code, reason) {
await link.messages.shutdownConnection.send(this); await link.messages.prepareDisconnect.send(this);
this.connector.close(code, reason); this.connector.close(code, reason);
await events.once(this.connector, "close"); await events.once(this.connector, "close");
} }
+1 -1
View File
@@ -740,7 +740,7 @@ class Slave extends link.Link {
} }
async shutdown() { async shutdown() {
await link.messages.shutdownConnection.send(this); await link.messages.prepareDisconnect.send(this);
for (let instanceId of this.instanceConnections.keys()) { for (let instanceId of this.instanceConnections.keys()) {
await this.stopInstance(instanceId); await this.stopInstance(instanceId);
} }
+1 -1
View File
@@ -12,7 +12,7 @@ class TestControl extends link.Link {
link.attachAllMessages(this); link.attachAllMessages(this);
} }
async shutdownConnectionRequestHandler() { } async prepareDisconnectRequestHandler() { }
async instanceOutputEventHandler() { } async instanceOutputEventHandler() { }
} }