mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-19 23:33:13 +09:00
Reimplement the Storage page
Reimplement the functionality of the Storage page which shows which items are stored in the shared subspace on the master server.
This commit is contained in:
1 parent
cebe83542f
commit
c16dc74ad9
5 files changed
+234
-3
No files matched your search
@@ -72,6 +72,8 @@ class MasterPlugin extends libPlugin.BaseMasterPlugin {
|
||||
}
|
||||
}, 1000);
|
||||
|
||||
this.subscribedControlLinks = new Set();
|
||||
|
||||
routes.addApiRoutes(this.master.app, this.items, this.metrics.endpointHitCounter);
|
||||
}
|
||||
|
||||
@@ -90,6 +92,9 @@ class MasterPlugin extends libPlugin.BaseMasterPlugin {
|
||||
|
||||
itemsToUpdate = [...itemsToUpdate.entries()];
|
||||
this.broadcastEventToSlaves(this.info.messages.updateStorage, { items: itemsToUpdate });
|
||||
for (let link of this.subscribedControlLinks) {
|
||||
this.info.messages.updateStorage.send(link, { items: itemsToUpdate });
|
||||
}
|
||||
this.itemsLastUpdate = new Map(this.items._items.entries());
|
||||
}
|
||||
|
||||
@@ -181,6 +186,20 @@ class MasterPlugin extends libPlugin.BaseMasterPlugin {
|
||||
};
|
||||
}
|
||||
|
||||
async setStorageSubscriptionRequestHandler(message, request, link) {
|
||||
if (message.data.storage) {
|
||||
this.subscribedControlLinks.add(link);
|
||||
} else {
|
||||
this.subscribedControlLinks.delete(link);
|
||||
}
|
||||
}
|
||||
|
||||
onControlConnectionEvent(connection, event) {
|
||||
if (event === "close") {
|
||||
this.subscribedControlLinks.delete(connection);
|
||||
}
|
||||
}
|
||||
|
||||
onMetrics() {
|
||||
if (this.items) {
|
||||
for (let [key, count] of this.items._items) {
|
||||
|
||||
Reference in new issue
Block a user