Skip to main content

Engine

Struct Engine 

Source
pub struct Engine { /* private fields */ }
Expand description

Main engine for schema synchronization

The engine coordinates all components to provide schema sync functionality. It’s designed to be used by the CLI layer, which handles mode-specific behavior (dry-run, validation, etc.).

Implementations§

Source§

impl Engine

Source

pub fn new( inspector: Box<dyn SchemaInspector>, runner: Box<dyn MigrationRunner>, planner: Box<dyn Planner>, executor: Box<dyn Executor>, diff_calculator: Box<dyn DiffCalculator>, snapshot_store: Option<Box<dyn SnapshotStore>>, ) -> Self

Create a new engine

§Arguments
  • inspector - Schema inspector for reading current schema
  • runner - Migration runner for executing changes
  • planner - Planner for creating migration plans
  • executor - Executor for orchestrating execution
  • diff_calculator - Calculator for computing diffs
  • snapshot_store - Optional snapshot store for versioning
Source

pub fn from_adapter( adapter: Box<dyn DatabaseAdapter>, planner: Box<dyn Planner>, executor: Box<dyn Executor>, diff_calculator: Box<dyn DiffCalculator>, snapshot_store: Option<Box<dyn SnapshotStore>>, ) -> Self

Create an engine from a database adapter

This is a convenience method that creates an engine with default implementations of planner, executor, and diff calculator.

Source

pub async fn sync_tenant( &self, tenant: &TenantContext, target: Option<&SchemaSnapshot>, execute: bool, ) -> Result<SyncResult>

Sync a tenant’s schema to match a target snapshot

This is the main operation. It:

  1. Inspects the current schema
  2. Calculates the diff to the target
  3. Creates a migration plan
  4. Optionally executes the plan
§Arguments
  • tenant - The tenant context
  • target - Target schema snapshot (or None to use stored snapshot)
  • execute - Whether to actually execute the migration (false for dry-run)
§Returns

Sync result with diff and execution details.

Source

pub async fn inspect_tenant( &self, tenant: &TenantContext, ) -> Result<SchemaSnapshot>

Get the current schema snapshot for a tenant

Source

pub fn calculate_diff( &self, from: &SchemaSnapshot, to: &SchemaSnapshot, ) -> SchemaDiff

Calculate diff between two snapshots

Source

pub async fn list_tenants(&self) -> Result<Vec<TenantContext>>

List all tenants

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.