Skip to main content

ensure_sqlite_memory_shared

Function ensure_sqlite_memory_shared 

Source
pub fn ensure_sqlite_memory_shared(
    config: &CamelConfig,
) -> Result<(), CamelError>
Expand description

Boot-time lint (ungated): rejects per-connection sqlite :memory: datasource URLs, which give every pooled connection its own private in-memory database — an INSERT through one connection and a SELECT through another can hit different databases.

The remediation message names two accepted forms:

  • Named shared-memory URI, the scenario-tier convention, e.g. sqlite:file:memdb_appdb?mode=memory&cache=shared. All pool connections share one named in-memory database; the name is stable across connections and parses with the sqlx driver. sqlite:file: matches no automatic datasource factory prefix (factories match scheme:// or scheme::), so the config must also pin provider = "sqlx".
  • Bare shared cache, sqlite::memory:?cache=shared. Accepted, but each parse gets a sqlx-assigned private name, and pool connections under the Any driver can hold private databases — pin max_connections = 1 with this form.

Iterates config.datasources in BTreeMap order (the config stores a HashMap, whose iteration order is unspecified) so diagnostics are deterministic. The error names the datasource only, never its URL (ADR-0051 credential redaction).