Skip to main content

DataBackfill

Trait DataBackfill 

Source
pub trait DataBackfill:
    Send
    + Sync
    + 'static {
    // Required methods
    fn name(&self) -> &'static str;
    fn run_batch<'life0, 'life1, 'async_trait>(
        &'life0 self,
        tx: &'life1 mut Transaction<Backfill>,
        offset: u64,
    ) -> Pin<Box<dyn Future<Output = Result<Option<u64>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided methods
    fn requires(&self) -> &'static [&'static str] { ... }
    fn batch_size(&self) -> usize { ... }
    fn log_interval(&self) -> usize { ... }
    fn batch_delay(&self) -> Duration { ... }
}
Expand description

A background migration that copies or transforms data in batches.

Required Methods§

Source

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

Source

fn run_batch<'life0, 'life1, 'async_trait>( &'life0 self, tx: &'life1 mut Transaction<Backfill>, offset: u64, ) -> Pin<Box<dyn Future<Output = Result<Option<u64>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Process one batch starting at offset.

Returns Some(next_offset) to continue, or None when all rows have been processed.

The transaction runs at READ COMMITTED on Postgres (see Backfill), so batches must be idempotent — typically by writing with ON CONFLICT and advancing a monotonic cursor.

Provided Methods§

Source

fn requires(&self) -> &'static [&'static str]

Names of other DataBackfill migrations that must complete before this one starts.

Source

fn batch_size(&self) -> usize

Number of rows to process per batch.

Source

fn log_interval(&self) -> usize

Number of batches between progress log lines.

Source

fn batch_delay(&self) -> Duration

How long to sleep between batches to avoid saturating the database.

Implementors§