Skip to main content

Module instance_registry

Module instance_registry 

Source
Expand description

Operator-declared instance registry. Step 3 of browser-multi-instance.

Maps each instance label (operator YAML browser[].instance) to its Arc<BrowserPlugin> — one Chrome handle per declared instance.

Mirrors the multi-instance pattern from nexo-rs-plugin-whatsapp/src/bot_registry.rs:28: OnceLock<Arc<DashMap<String, ...>>> — same Arc<DashMap> instance shared across the boot loop (on_configure), the dispatch resolver (dispatch::resolve_plugin, Step 5), and admin RPC handlers (admin::list_instances, Step 7).

This registry coexists with the legacy per-agent_id PROFILES map in main.rs (Phase 81.17.c.multi-profile). When the registry is empty, dispatch falls back to the legacy map; when populated, it wins.

Functions§

clear
Drop every entry. Used by tests; production callers should diff against entries and unregister individual labels so live Chromes can be shut down cleanly.
entries
Snapshot every (label, plugin) pair. Useful for the dispatcher’s “exactly-one-declared” compat shim + admin list_instances.
len
Number of declared instances. O(1).
lookup
Look up the live Arc<BrowserPlugin> for label.
register
Register plugin under label. Overwrites any prior entry — callers that need diff-aware behaviour (the boot loop) compare against entries before re-registering.
unregister
Drop the entry for label. Returns the prior Arc<BrowserPlugin> so the caller can .shutdown_chrome().await on the removed value.