Documentation
¶
Overview ¶
Package providers adds ONE thing on top of togo's existing provider system: runtime, config-driven SELECTION of which backend is active for a capability — swappable over CLI / .env / settings without recompiling.
It deliberately reuses what the framework already has and invents nothing new:
- the registry → togo.RegisterProviderFunc / applyProviders
- the capability contracts → togo.Cache / Queue / Storage / Broker / Translator (new ones like Implement/Execute/Compute live in the plugin that owns them)
- the container → k.Set(capability, impl) / k.Get(capability)
- the config store → github.com/togo-framework/settings (scope "providers")
- the <cap>-<backend> convention → storage-s3, realtime-nats, queue-nats, …
A backend plugin calls Use() in its provider func: it installs itself as the capability service only when it is the selected (or default) backend. Selection resolves highest-first: (1) env TOGO_<CAP>_PROVIDER, (2) settings providers.<cap>.active, (3) the caller's default.
Index ¶
Constants ¶
const ( // --- already defined by togo core (contracts.go) — reuse, don't redefine --- CapCache = "cache" // togo.Cache CapQueue = "queue" // togo.Queue → queue-nats (default), queue-rabbitmq, queue-kafka CapStorage = "storage" // togo.Storage → storage-s3, storage-r2, storage-gdrive CapRealtime = "realtime" // togo.Broker → realtime-nats, realtime-grpc // --- new capabilities (contract lives in the owning plugin) --- CapImplement = "impl" // autopilot: issue → code. claude (default), omnigent CapExecute = "exec" // autopilot: isolated env. local (default), coder CapCompute = "compute" // worker: batch/stream jobs. worker-local (default), beam/spark/flink/databricks CapData = "data" // db: governed read/write. pg (default), iceberg/bigquery/databricks CapCatalog = "catalog" // catalog: Unity Catalog / Iceberg REST )
Capability names — the shared vocabulary for provider selection. Some already have a contract in togo core (contracts.go); the selection helper in this package works for ANY capability string, existing or new.
Variables ¶
This section is empty.
Functions ¶
func Active ¶
Active returns the selected backend name for a capability, or def if none is configured. Resolution order: env → settings("providers") → def.
func Use ¶
Use installs impl as the capability's kernel service IF this backend is the selected one — or, when def is true, if nothing else is selected. Returns whether it took effect. Call it from a backend plugin's provider func:
togo.RegisterProviderFunc("db-iceberg", togo.PriorityService, func(k *togo.Kernel) error {
providers.Use(k, providers.CapData, "iceberg", newIceberg(k), false)
return nil
})
Types ¶
This section is empty.