class
Memo::Namespaces
- Memo::Namespaces
- Reference
- Object
Overview
Registry of Memo::Service instances keyed by namespace (ns).
Each ns has its own database, embedding service, and USearch index — providing true isolation between projects sharing one memo-arcana process.
Namespaces are listed in a config file (some preloaded at boot), or
registered with #open when allow_open is set. Once opened, services
are cached in memory until explicitly closed (or the process exits).
Defined in:
arcana/namespaces.crConstructors
Instance Method Summary
-
#allow_open=(allow_open : Bool)
Whether
#openmay register a namespace the config file doesn't list. -
#allow_open? : Bool
Whether
#openmay register a namespace the config file doesn't list. -
#close(ns : String) : Bool
Close and remove a namespace.
-
#close_all
Close all open services (called on shutdown), each after its in-flight requests finish.
- #configs : Hash(String, Config)
-
#get(ns : String) : Memo::Service
Get the Memo::Service for a namespace, opening it lazily if needed.
-
#list : Array(Tuple(String, Bool))
List all registered namespaces with their open status.
-
#load_config(path : String)
Load namespace configs from a YAML-ish config file.
-
#open(config : Config) : Memo::Service
Register and immediately open a namespace.
-
#open_services : Array(Tuple(String, Memo::Service))
Snapshot of the open services, for work done outside the lock (e.g.
-
#preload_all
Preload all namespaces marked with preload: true in their config.
-
#register(config : Config)
Register a namespace config (without opening).
- #services : Hash(String, Memo::Service)
-
#use(ns : String, &)
Run the block with the namespace's service, opening it if needed.
Constructor Detail
Instance Method Detail
Whether #open may register a namespace the config file doesn't list.
Off by default, since the requester picks the database.
Whether #open may register a namespace the config file doesn't list.
Off by default, since the requester picks the database.
Close and remove a namespace. Waits for an open in progress, and for requests already using the service (see use). New requests wait, then open it afresh.
Close all open services (called on shutdown), each after its in-flight requests finish.
Get the Memo::Service for a namespace, opening it lazily if needed. Raises if the namespace isn't registered.
Opening can be slow (it may replay or rebuild the index), so it holds only that namespace's open lock; requests for other namespaces carry on.
Load namespace configs from a YAML-ish config file.
Format (very simple, one block per namespace):
namespaces: - ns: wow db: postgres://wow:wow@localhost/wow_dev service: openai preload: true - ns: notes db: /var/lib/memo/notes.db service: mock
Register and immediately open a namespace. Returns the Service.
A namespace already registered keeps its settings: opening it again with the same database just opens it, and with another one raises. Registering a new one needs allow_open, and it's dropped again if it fails to open, so a corrected open can follow.
Snapshot of the open services, for work done outside the lock (e.g. periodic index saves).
Run the block with the namespace's service, opening it if needed. close waits for blocks already running before it closes the service.