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() {
await link.messages.shutdownConnection.send(this);
await link.messages.prepareDisconnect.send(this);
this.connector.close(1001, "Control Quit")
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.
Graceful shutdown
-----------------
Graceful Disconnect
-------------------
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
and the party sending the request should be the one that initates the
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
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
should the response be sent.
### `connection_shutdown_response`
### `prepare_disconnect_response`
Signals the shutdown is complete and that the connection can be closed.
The party that initiatied the shutdown request may still send other
requests/events over the link to finish its part of the shutdown.
Signals the preparation for disconnect is complete and that the
connection can be closed. The party that initiatied the prepare
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
possible and treated as a success.
+2 -2
View File
@@ -208,14 +208,14 @@ class Link {
async pingRequestHandler() { }
/**
* Prepare connection for close
* Prepare connection for disconnect
*
* Waits for all pending requests on the connection to resolve.
* Sub-classes should implement this handler with code that prevents
* additional requests to be sent out before calling the super class
* method.
*/
async shutdownConnectionRequestHandler() {
async prepareDisconnectRequestHandler() {
let promises = [];
for (let waiterType of this._waiters.values()) {
for (let waiter of waiterType) {
+2 -2
View File
@@ -185,8 +185,8 @@ let messages = {}
// Connection requests
let wsLinks = ["master-control", "control-master", "master-slave", "slave-master"];
messages.shutdownConnection = new Request({
type: "shutdown_connection",
messages.prepareDisconnect = new Request({
type: "prepare_disconnect",
links: wsLinks,
});
+1 -1
View File
@@ -381,7 +381,7 @@ class BaseConnection extends link.Link {
}
async shutdown(code, reason) {
await link.messages.shutdownConnection.send(this);
await link.messages.prepareDisconnect.send(this);
this.connector.close(code, reason);
await events.once(this.connector, "close");
}
+1 -1
View File
@@ -740,7 +740,7 @@ class Slave extends link.Link {
}
async shutdown() {
await link.messages.shutdownConnection.send(this);
await link.messages.prepareDisconnect.send(this);
for (let instanceId of this.instanceConnections.keys()) {
await this.stopInstance(instanceId);
}
+1 -1
View File
@@ -12,7 +12,7 @@ class TestControl extends link.Link {
link.attachAllMessages(this);
}
async shutdownConnectionRequestHandler() { }
async prepareDisconnectRequestHandler() { }
async instanceOutputEventHandler() { }
}