mirror of https://github.com/openclaw/openclaw.git
refactor(plugins): make runtime registry lazy
This commit is contained in:
parent
e16f0cf908
commit
6451beddb2
|
|
@ -1,6 +1,7 @@
|
|||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import { createEmptyPluginRegistry } from "./registry.js";
|
||||
import {
|
||||
getActivePluginRegistry,
|
||||
pinActivePluginHttpRouteRegistry,
|
||||
releasePinnedPluginHttpRouteRegistry,
|
||||
resetPluginRuntimeStateForTest,
|
||||
|
|
@ -14,6 +15,12 @@ describe("plugin runtime route registry", () => {
|
|||
resetPluginRuntimeStateForTest();
|
||||
});
|
||||
|
||||
it("stays empty until a caller explicitly installs or requires a registry", () => {
|
||||
resetPluginRuntimeStateForTest();
|
||||
|
||||
expect(getActivePluginRegistry()).toBeNull();
|
||||
});
|
||||
|
||||
it("keeps the pinned route registry when the active plugin registry changes", () => {
|
||||
const startupRegistry = createEmptyPluginRegistry();
|
||||
const laterRegistry = createEmptyPluginRegistry();
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ const state: RegistryState = (() => {
|
|||
};
|
||||
if (!globalState[REGISTRY_STATE]) {
|
||||
globalState[REGISTRY_STATE] = {
|
||||
registry: createEmptyPluginRegistry(),
|
||||
registry: null,
|
||||
httpRouteRegistry: null,
|
||||
httpRouteRegistryPinned: false,
|
||||
key: null,
|
||||
|
|
@ -100,9 +100,8 @@ export function getActivePluginRegistryVersion(): number {
|
|||
}
|
||||
|
||||
export function resetPluginRuntimeStateForTest(): void {
|
||||
const emptyRegistry = createEmptyPluginRegistry();
|
||||
state.registry = emptyRegistry;
|
||||
state.httpRouteRegistry = emptyRegistry;
|
||||
state.registry = null;
|
||||
state.httpRouteRegistry = null;
|
||||
state.httpRouteRegistryPinned = false;
|
||||
state.key = null;
|
||||
state.version += 1;
|
||||
|
|
|
|||
Loading…
Reference in New Issue