mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-24 00:23:12 +09:00
Fix incorrect instance lookups in plugins
Fix mistaken lookups missing the instance part, or trying to get the id from the removed instance.id property.
This commit is contained in:
1 parent
1e6b807ae3
commit
6f22942cc5
3 files changed
+7
-4
No files matched your search
@@ -226,7 +226,7 @@ plugin you listen for an event named ipc-channel_name in order to get
|
|||||||
data sent by `send_json`. For example in the plugin code:
|
data sent by `send_json`. For example in the plugin code:
|
||||||
|
|
||||||
async init() {
|
async init() {
|
||||||
this.server.on('ipc-my_plugin_foo', content =>
|
this.instance.server.on('ipc-my_plugin_foo', content =>
|
||||||
this.handleFoo(content).catch(err => console.log(
|
this.handleFoo(content).catch(err => console.log(
|
||||||
"Error handling foo:", foo
|
"Error handling foo:", foo
|
||||||
))
|
))
|
||||||
@@ -478,7 +478,7 @@ accordingly, for example:
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Somewhere in the instance plugin code
|
// Somewhere in the instance plugin code
|
||||||
barMetric.labels(String(this.config.id)).set(someValue);
|
barMetric.labels(String(this.instance.config.get("instance.id"))).set(someValue);
|
||||||
|
|
||||||
Metrics are automatically registered to the default registry, and this
|
Metrics are automatically registered to the default registry, and this
|
||||||
default registry is automatically polled by the master server on slaves.
|
default registry is automatically polled by the master server on slaves.
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class InstancePlugin extends plugin.BaseInstancePlugin {
|
|||||||
throw new Error(`Error parsing statistics JSON: ${err.message}, content "${string}"`);
|
throw new Error(`Error parsing statistics JSON: ${err.message}, content "${string}"`);
|
||||||
}
|
}
|
||||||
|
|
||||||
let instanceId = this.instance.config.id;
|
let instanceId = this.instance.config.get("instance.id");
|
||||||
instanceGameTicksTotal.labels(String(instanceId)).set(stats.game_tick);
|
instanceGameTicksTotal.labels(String(instanceId)).set(stats.game_tick);
|
||||||
instancePlayerCount.labels(String(instanceId)).set(stats.player_count);
|
instancePlayerCount.labels(String(instanceId)).set(stats.player_count);
|
||||||
|
|
||||||
|
|||||||
+4
-1
@@ -72,7 +72,10 @@ class MockInstance extends link.Link {
|
|||||||
this.server = new MockServer();
|
this.server = new MockServer();
|
||||||
this.name = "test";
|
this.name = "test";
|
||||||
this.config = {
|
this.config = {
|
||||||
id: 7357,
|
get: (name) => {
|
||||||
|
if (name === "instance.id") { return 7357 }
|
||||||
|
throw Error("Not implemented");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user