Skip to main content

build

Function build 

Source
pub async fn build(cfg: EngineConfig) -> Result<EmbeddedEngine>
Expand description

Build engine for embedding. Internally:

  1. Open pool against cfg.backend via EngineBoot::run (which also runs engine + per-module schema migrations).
  2. Bootstrap module contexts (auth, vault, workflow).
  3. Enforce preconditions — refuse to start when auth is on and the deployment has no operator users, no admin api-keys, and no external OIDC issuers (would lock the operator out).
  4. Compose axum::Router via crate::server::build_app.
  5. Spawn engine’s background tasks (events outbox cleanup; module-specific schedulers spawn during ctx construction).

Returns Err on any of: pool-open failure, migration failure, ctx-build failure, precondition failure. The Err carries a helpful operator-facing message when the cause is configuration.