mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-27 00:52:05 +00:00
refactor(runtime): harden channel-registry cache invalidation and split outbound delivery flow
This commit is contained in:
@@ -5,6 +5,7 @@ const REGISTRY_STATE = Symbol.for("openclaw.pluginRegistryState");
|
||||
type RegistryState = {
|
||||
registry: PluginRegistry | null;
|
||||
key: string | null;
|
||||
version: number;
|
||||
};
|
||||
|
||||
const state: RegistryState = (() => {
|
||||
@@ -15,6 +16,7 @@ const state: RegistryState = (() => {
|
||||
globalState[REGISTRY_STATE] = {
|
||||
registry: createEmptyPluginRegistry(),
|
||||
key: null,
|
||||
version: 0,
|
||||
};
|
||||
}
|
||||
return globalState[REGISTRY_STATE];
|
||||
@@ -23,6 +25,7 @@ const state: RegistryState = (() => {
|
||||
export function setActivePluginRegistry(registry: PluginRegistry, cacheKey?: string) {
|
||||
state.registry = registry;
|
||||
state.key = cacheKey ?? null;
|
||||
state.version += 1;
|
||||
}
|
||||
|
||||
export function getActivePluginRegistry(): PluginRegistry | null {
|
||||
@@ -32,6 +35,7 @@ export function getActivePluginRegistry(): PluginRegistry | null {
|
||||
export function requireActivePluginRegistry(): PluginRegistry {
|
||||
if (!state.registry) {
|
||||
state.registry = createEmptyPluginRegistry();
|
||||
state.version += 1;
|
||||
}
|
||||
return state.registry;
|
||||
}
|
||||
@@ -39,3 +43,7 @@ export function requireActivePluginRegistry(): PluginRegistry {
|
||||
export function getActivePluginRegistryKey(): string | null {
|
||||
return state.key;
|
||||
}
|
||||
|
||||
export function getActivePluginRegistryVersion(): number {
|
||||
return state.version;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user