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§
fn name(&self) -> &'static str
Sourcefn 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,
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§
Sourcefn requires(&self) -> &'static [&'static str]
fn requires(&self) -> &'static [&'static str]
Names of other DataBackfill migrations that must complete before this one starts.
Sourcefn batch_size(&self) -> usize
fn batch_size(&self) -> usize
Number of rows to process per batch.
Sourcefn log_interval(&self) -> usize
fn log_interval(&self) -> usize
Number of batches between progress log lines.
Sourcefn batch_delay(&self) -> Duration
fn batch_delay(&self) -> Duration
How long to sleep between batches to avoid saturating the database.