mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-12 23:04:52 +09:00
Add controller.autosave_interval config that specifies the frequency which controller config, hosts, instances, users, mod packs and plugin specific data which is held in memory should be automatically flushed to disk if they have changed since the last time they were saved. This prevents data loss in the event of a server crash. Plugins can use the onSaveData hook to save its own data at the same time as the controller does and this obsoletes making an autosave interval in the plugin. Resolves #523.
63 lines
1.9 KiB
TypeScript
63 lines
1.9 KiB
TypeScript
import * as lib from "@clusterio/lib";
|
|
import * as messages from "./messages";
|
|
|
|
class ControllerConfigGroup extends lib.PluginConfigGroup {}
|
|
ControllerConfigGroup.defaultAccess = ["controller", "host", "control"];
|
|
ControllerConfigGroup.groupName = "subspace_storage";
|
|
ControllerConfigGroup.define({
|
|
name: "division_method",
|
|
title: "Division Method",
|
|
description: "Method for dividing resource requests between instances.",
|
|
type: "string",
|
|
enum: ["simple", "dole", "neural_dole"],
|
|
initial_value: "simple",
|
|
});
|
|
ControllerConfigGroup.define({
|
|
name: "log_item_transfers",
|
|
title: "Log Item Transfers",
|
|
description: "Spam controller console with item transfers done.",
|
|
type: "boolean",
|
|
initial_value: false,
|
|
});
|
|
ControllerConfigGroup.finalize();
|
|
|
|
class InstanceConfigGroup extends lib.PluginConfigGroup {}
|
|
InstanceConfigGroup.defaultAccess = ["controller", "host", "control"];
|
|
InstanceConfigGroup.groupName = "subspace_storage";
|
|
InstanceConfigGroup.define({
|
|
name: "log_item_transfers",
|
|
title: "Log Item Transfers",
|
|
description: "Spam host console with item transfers done.",
|
|
type: "boolean",
|
|
initial_value: false,
|
|
});
|
|
InstanceConfigGroup.finalize();
|
|
|
|
lib.definePermission({
|
|
name: "subspace_storage.storage.view",
|
|
title: "View Subspace Storage",
|
|
description: "View the items and fluids stored in the shared subspace.",
|
|
grantByDefault: true,
|
|
});
|
|
|
|
export default {
|
|
name: "subspace_storage",
|
|
title: "Subspace Storage",
|
|
description: "Provides shared storage across instances for the Subspace Storage mod",
|
|
instanceEntrypoint: "dist/plugin/instance",
|
|
InstanceConfigGroup,
|
|
|
|
controllerEntrypoint: "dist/plugin/controller",
|
|
ControllerConfigGroup,
|
|
|
|
messages: [
|
|
messages.PlaceEvent,
|
|
messages.RemoveRequest,
|
|
messages.GetStorageRequest,
|
|
messages.UpdateStorageEvent,
|
|
messages.SetStorageSubscriptionRequest,
|
|
],
|
|
webEntrypoint: "./web",
|
|
routes: ["/storage"],
|
|
} satisfies lib.PluginDeclaration;
|