mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 09:20:43 +00:00
perf(plugins): isolate manifest registry cache state
This commit is contained in:
10
src/plugins/manifest-registry-state.ts
Normal file
10
src/plugins/manifest-registry-state.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
export type PluginManifestRegistryCacheEntry = {
|
||||
expiresAt: number;
|
||||
registry: unknown;
|
||||
};
|
||||
|
||||
export const pluginManifestRegistryCache = new Map<string, PluginManifestRegistryCacheEntry>();
|
||||
|
||||
export function clearPluginManifestRegistryCache(): void {
|
||||
pluginManifestRegistryCache.clear();
|
||||
}
|
||||
@@ -15,6 +15,10 @@ import {
|
||||
} from "./config-policy.js";
|
||||
import { discoverOpenClawPlugins, type PluginCandidate } from "./discovery.js";
|
||||
import type { PluginManifestCommandAlias } from "./manifest-command-aliases.js";
|
||||
import {
|
||||
clearPluginManifestRegistryCache,
|
||||
pluginManifestRegistryCache,
|
||||
} from "./manifest-registry-state.js";
|
||||
import type {
|
||||
PluginBundleFormat,
|
||||
PluginConfigUiHint,
|
||||
@@ -117,14 +121,15 @@ export type PluginManifestRegistry = {
|
||||
diagnostics: PluginDiagnostic[];
|
||||
};
|
||||
|
||||
const registryCache = new Map<string, { expiresAt: number; registry: PluginManifestRegistry }>();
|
||||
const registryCache = pluginManifestRegistryCache as Map<
|
||||
string,
|
||||
{ expiresAt: number; registry: PluginManifestRegistry }
|
||||
>;
|
||||
|
||||
// Keep a short cache window to collapse bursty reloads during startup flows.
|
||||
const DEFAULT_MANIFEST_CACHE_MS = 1000;
|
||||
|
||||
export function clearPluginManifestRegistryCache(): void {
|
||||
registryCache.clear();
|
||||
}
|
||||
export { clearPluginManifestRegistryCache } from "./manifest-registry-state.js";
|
||||
|
||||
function listContractValues(
|
||||
plugin: PluginManifestRecord,
|
||||
|
||||
@@ -16,7 +16,7 @@ import { drainSessionStoreLockQueuesForTest } from "../src/config/sessions/store
|
||||
import { drainFileLockStateForTest, resetFileLockStateForTest } from "../src/infra/file-lock.js";
|
||||
import type { OutboundSendDeps } from "../src/infra/outbound/deliver.js";
|
||||
import { clearPluginDiscoveryCache } from "../src/plugins/discovery.js";
|
||||
import { clearPluginManifestRegistryCache } from "../src/plugins/manifest-registry.js";
|
||||
import { clearPluginManifestRegistryCache } from "../src/plugins/manifest-registry-state.js";
|
||||
import type { PluginRegistry } from "../src/plugins/registry.js";
|
||||
import { resetPluginRuntimeStateForTest, setActivePluginRegistry } from "../src/plugins/runtime.js";
|
||||
import { installSharedTestSetup } from "./setup.shared.js";
|
||||
|
||||
Reference in New Issue
Block a user