1"""Explicit-import connector registration.
5- oc_diagnostics (_dbg structured logger)
6- oc_connect.connectors.telegram (lazy; the shipped Telegram bundle, imported for its registration side effect)
8from __future__
import annotations
10from oc_diagnostics
import _dbg
14 """Small in-memory registry with fail-loud conflict handling."""
19 def register(self, name: str, connector: object) -> object:
20 """Register a connector object, allowing only identical repeats."""
22 raise ValueError(
"connector name must not be blank")
24 if existing
is not None and existing
is not connector:
25 raise ValueError(f
"connector {name!r} is already registered")
27 _dbg(
"OC_CONNECT.REGISTRY",
"register", f
"registered connector {name}", 3)
30 def get(self, name: str) -> object:
31 """Return a registered connector or fail with its public name."""
35 raise KeyError(f
"connector {name!r} is not registered")
from None
37 def names(self) -> tuple[str, ...]:
38 """Return registered names in deterministic order."""
42 """Remove registrations; intended for isolated tests."""
50 """Load shipped bundles by explicit import, never entry points."""
51 from .connectors
import telegram
as _telegram
54 "OC_CONNECT.REGISTRY",
55 "load_builtin_connectors",
56 f
"loaded bundle module {_telegram.__name__}",
62__all__ = [
"ConnectorRegistry",
"load_builtin_connectors",
"registry"]
object get(self, str name)
object register(self, str name, object connector)
tuple[str,...] names(self)
ConnectorRegistry load_builtin_connectors()