Skip to main content

Backend

Trait Backend 

Source
pub trait Backend: Send + Sync {
    // Required method
    fn kind(&self) -> BackendKind;

    // Provided methods
    fn enabled(&self) -> bool { ... }
    fn capabilities(&self) -> BackendCapability { ... }
    fn dsn_scheme(&self) -> String { ... }
    fn default_dsn_env(&self) -> &'static str { ... }
    fn contract(&self) -> BackendPluginContract { ... }
    fn conformance_report(&self) -> BackendConformanceReport { ... }
    fn register<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        _ctx: &'life1 mut RegisterCtx<'life2>,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
    fn generate_artifacts(
        &self,
        _manifest: &CatalogManifest,
        _sql_config: &SqlGenerationConfig,
    ) -> Result<Vec<GeneratedArtifact>, String> { ... }
    fn sync_subdir(&self) -> &'static str { ... }
}
Expand description

A plugin module describing one backend.

Implementors are typically zero-sized structs with one pub static instance per backend (see backend::plugins).

Required Methods§

Source

fn kind(&self) -> BackendKind

The canonical identity of this backend.

All other defaulted methods derive their value from this; an override is only needed if a plugin wants to deviate from the enum’s metadata.

Provided Methods§

Source

fn enabled(&self) -> bool

Whether this backend is compiled into the current build.

Defaulted to true. Plugins for feature-gated backends (s3, redis, kafka, …) override this by sitting behind #[cfg(feature = "…")] themselves; the slim build simply doesn’t include them in all_plugins.

Source

fn capabilities(&self) -> BackendCapability

Capability flags (delegates to BackendKind).

Source

fn dsn_scheme(&self) -> String

udb+<tier>+<backend> URI scheme prefix (delegates to BackendKind).

Source

fn default_dsn_env(&self) -> &'static str

Default environment variable holding the connection DSN (delegates to BackendKind).

Source

fn contract(&self) -> BackendPluginContract

Stable plugin contract advertised by this backend.

Source

fn conformance_report(&self) -> BackendConformanceReport

Validate this plugin’s contract.

Source

fn register<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _ctx: &'life1 mut RegisterCtx<'life2>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Wire this backend into the runtime under construction.

Default: no-op. Plugins override this to move their per-backend setup block out of DataBrokerRuntime::from_config (pool creation, HTTP client, instance map, *_configured flag, any warnings). Per §9.1 this is the connection layer only — replica routing, channels, breakers, cache, and encryption stay in orchestration.

Source

fn generate_artifacts( &self, _manifest: &CatalogManifest, _sql_config: &SqlGenerationConfig, ) -> Result<Vec<GeneratedArtifact>, String>

Generate the migration artifacts this backend ships for the given AST.

Default: empty. Plugins for backends with a generator (generation::<backend>::generate_<backend>_artifacts) override this to delegate. BackendKind::Postgres keeps the default — its bootstrap SQL is produced via the separate generate_bootstrap_sql path because it also takes a CatalogManifest.

Source

fn sync_subdir(&self) -> &'static str

Subdirectory name under db_ops/ where this backend’s artifacts are written by sync_all_backends. Defaults to the canonical token; only override when the directory layout deviates (none today).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§