Rename Master to Controller

The role of the master server as the party controlling every part of the
cluster is not well reflected in its name and has caused confusion among
users on several occasions.  Rename master to controller to better
reflects its role.
This commit is contained in:
Hornwitser committed 2023-02-22 15:30:51 +01:00
1 parent 6ae4c8ef46
commit 70ad295a89
119 files changed
+1394 -1376

No files matched your search

+2 -2
View File
@@ -8,6 +8,6 @@ Plugin synchronizing research progress between instances and the cluster.
Run the following commands in the folder Clusterio is installed to:
npm install @clusterio/plugin-research_sync
npx clusteriomaster plugin add @clusterio/plugin-research_sync
npx clusteriocontroller plugin add @clusterio/plugin-research_sync
Substitute clusteriomaster with clusterioslave or clusterioctl if this a dedicate slave or ctl installation respectively.
Substitute clusteriocontroller with clusterioslave or clusterioctl if this a dedicate slave or ctl installation respectively.
@@ -7,8 +7,8 @@ const libPlugin = require("@clusterio/lib/plugin");
const RateLimiter = require("@clusterio/lib/RateLimiter");
async function loadTechnologies(masterConfig, logger) {
let filePath = path.join(masterConfig.get("master.database_directory"), "technologies.json");
async function loadTechnologies(controllerConfig, logger) {
let filePath = path.join(controllerConfig.get("controller.database_directory"), "technologies.json");
logger.verbose(`Loading ${filePath}`);
try {
return new Map(JSON.parse(await fs.readFile(filePath)));
@@ -23,15 +23,15 @@ async function loadTechnologies(masterConfig, logger) {
}
}
async function saveTechnologies(masterConfig, technologies, logger) {
let filePath = path.join(masterConfig.get("master.database_directory"), "technologies.json");
async function saveTechnologies(controllerConfig, technologies, logger) {
let filePath = path.join(controllerConfig.get("controller.database_directory"), "technologies.json");
logger.verbose(`writing ${filePath}`);
await libFileOps.safeOutputFile(filePath, JSON.stringify([...technologies.entries()], null, 4));
}
class MasterPlugin extends libPlugin.BaseMasterPlugin {
class ControllerPlugin extends libPlugin.BaseControllerPlugin {
async init() {
this.technologies = await loadTechnologies(this.master.config, this.logger);
this.technologies = await loadTechnologies(this.controller.config, this.logger);
this.progressRateLimiter = new RateLimiter({
maxRate: 1,
action: () => this.broadcastProgress(),
@@ -44,7 +44,7 @@ class MasterPlugin extends libPlugin.BaseMasterPlugin {
async onShutdown() {
this.progressRateLimiter.cancel();
await saveTechnologies(this.master.config, this.technologies, this.logger);
await saveTechnologies(this.controller.config, this.technologies, this.logger);
}
broadcastProgress() {
@@ -169,5 +169,5 @@ class MasterPlugin extends libPlugin.BaseMasterPlugin {
module.exports = {
MasterPlugin,
ControllerPlugin,
};
+9 -9
View File
@@ -2,7 +2,7 @@
const { libLink } = require("@clusterio/lib");
// schema used for syncing technologies to and from the master
// schema used for syncing technologies to and from the controller
const technologies = {
type: "array",
items: {
@@ -23,13 +23,13 @@ module.exports = {
title: "Research Sync",
description: "Synchronises technology research progress between instances.",
instanceEntrypoint: "instance",
masterEntrypoint: "master",
controllerEntrypoint: "controller",
messages: {
contribution: new libLink.Event({
type: "research_sync:contribution",
links: ["instance-slave", "slave-master"],
forwardTo: "master",
links: ["instance-slave", "slave-controller"],
forwardTo: "controller",
eventProperties: {
"name": { type: "string" },
"level": { type: "integer" },
@@ -38,7 +38,7 @@ module.exports = {
}),
progress: new libLink.Event({
type: "research_sync:progress",
links: ["master-slave", "slave-instance"],
links: ["controller-slave", "slave-instance"],
broadcastTo: "instance",
eventProperties: {
"technologies": {
@@ -57,8 +57,8 @@ module.exports = {
}),
finished: new libLink.Event({
type: "research_sync:finished",
links: ["instance-slave", "slave-master", "master-slave", "slave-instance"],
forwardTo: "master",
links: ["instance-slave", "slave-controller", "controller-slave", "slave-instance"],
forwardTo: "controller",
broadcastTo: "instance",
eventProperties: {
"name": { type: "string" },
@@ -67,8 +67,8 @@ module.exports = {
}),
syncTechnologies: new libLink.Request({
type: "research_sync:sync_technologies",
links: ["instance-slave", "slave-master"],
forwardTo: "master",
links: ["instance-slave", "slave-controller"],
forwardTo: "controller",
requestProperties: {
"technologies": technologies,
},
+3 -3
View File
@@ -66,8 +66,8 @@ class InstancePlugin extends libPlugin.BaseInstancePlugin {
let response = await this.info.messages.syncTechnologies.send(this.instance, { technologies: techsToSend });
this.syncStarted = true;
let techsToSync = [];
for (let masterTech of response.technologies) {
let [name, level, progress, researched] = masterTech;
for (let controllerTech of response.technologies) {
let [name, level, progress, researched] = controllerTech;
let instanceTech = instanceTechs.get(name);
if (
!instanceTech
@@ -75,7 +75,7 @@ class InstancePlugin extends libPlugin.BaseInstancePlugin {
|| (instanceTech.progress || null) !== progress
|| instanceTech.researched !== researched
) {
techsToSync.push(masterTech);
techsToSync.push(controllerTech);
}
}
+6 -6
View File
@@ -27,7 +27,7 @@ sync.events[clusterio_api.events.on_server_startup] = function(event)
}
end
-- Used when syncing completed technologies from the master
-- Used when syncing completed technologies from the controller
global.research_sync.ignore_research_finished = false
local force = game.forces["player"]
@@ -165,14 +165,14 @@ function research_sync.update_progress(data)
local techs = game.json_to_table(data)
local force = game.forces["player"]
for _, masterTech in ipairs(techs) do
local tech = force.technologies[masterTech.name]
if tech and tech.level == masterTech.level then
for _, controllerTech in ipairs(techs) do
local tech = force.technologies[controllerTech.name]
if tech and tech.level == controllerTech.level then
send_contribution(tech)
set_technology_progress(tech, masterTech.progress)
set_technology_progress(tech, controllerTech.progress)
global.research_sync.technologies[tech.name] = {
level = tech.level,
progress = masterTech.progress
progress = controllerTech.progress
}
end
end
+1 -1
View File
@@ -3,4 +3,4 @@
"use strict";
require("../instance");
require("../master");
require("../controller");