mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-16 23:30:41 +09:00
Refactor instance communication
Change Instance class to be a subclass of Link and refactor the communication to and establisment of instances to use a virtual connection between the slave and the instance. This is simplifies the implementation of plugin communication for instances. Replace InstanceRequest with a forwardTo option to Request which does the task of forwarding in a much cleaner way.
This commit is contained in:
1 parent
9f24d200b7
commit
5d8fa4e4ce
7 files changed
+381
-265
No files matched your search
@@ -255,7 +255,7 @@ class BaseConnection extends link.Link {
|
||||
link.attachAllMessages(this);
|
||||
}
|
||||
|
||||
async forwardInstanceRequest(request, message) {
|
||||
async forwardRequestToInstance(message, request) {
|
||||
let instance = db.instances.get(message.data.instance_id);
|
||||
if (!instance) {
|
||||
throw new errors.RequestError(`Instance with ID ${instance_id} does not exist`);
|
||||
@@ -266,7 +266,7 @@ class BaseConnection extends link.Link {
|
||||
throw new errors.RequestError("Slave containing instance is not connected");
|
||||
}
|
||||
|
||||
return await request.forward(connection, message);
|
||||
return await request.send(connection, message.data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user