Replace bootstrap methods with async factories

Controller.bootstrap and Host.bootstrap returned constructor arguments
that the caller had to spread into new Controller/Host, and
DatastoreProvider.bootstrap did the same for datastores. They are
replaced by Controller.fromConfig, Host.fromConfig and
KeyValueDatastore/SubscribableDatastore.fromProvider, which load the
data and return the finished instance.

Closes #1126

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
bbassieandClaude Opus 5.5 committed 2026-10-23 23:51:22 +00:00
1 parent c3abf27266
commit d7fc3aaec4
8 files changed
+133 -57

No files matched your search

+15
View File
@@ -62,6 +62,21 @@ describe("host/src/Host", function() {
});
});
describe("class Host", function() {
describe(".fromConfig()", function() {
const modsDirectory = path.join("temp", "test", "host_from_config", "mods");
beforeEach(async function() {
await fs.rm(path.dirname(modsDirectory), { recursive: true, force: true });
});
it("should create the mods directory and load the mod store", async function() {
const hostConfig = new lib.HostConfig("host", { "host.mods_directory": modsDirectory });
const host = await Host.fromConfig(new HostConnector(hostConfig, []), hostConfig, [], true, false);
assert(host instanceof Host);
assert.equal(host.canRestart, true);
assert.equal(host.recoveryMode, false);
assert.equal(host.modStore.modsDirectory, modsDirectory);
await fs.access(modsDirectory);
});
});
describe(".handleSyncUserListsEvent()", function() {
const hostAddress = lib.Address.fromShorthand({ hostId: 1 });
const instanceAddress = lib.Address.fromShorthand({ instanceId: 1 });