Skip to main content

StateStore

Struct StateStore 

Source
pub struct StateStore { /* private fields */ }

Implementations§

Source§

impl StateStore

Source

pub fn open(config_path: &str) -> Result<Self>

Source

pub fn state_db_path(config_path: &str) -> PathBuf

Path to .rivet_state.db next to the config file (same rules as open).

Source

pub fn find_in_progress_chunk_run( &self, export_name: &str, ) -> Result<Option<(String, String)>>

Latest in_progress chunk run for this export, if any.

Source

pub fn create_chunk_run( &self, run_id: &str, export_name: &str, plan_hash: &str, max_chunk_attempts: u32, ) -> Result<()>

Source

pub fn insert_chunk_tasks( &self, run_id: &str, ranges: &[(i64, i64)], ) -> Result<()>

Source

pub fn reset_stale_running_chunk_tasks(&self, run_id: &str) -> Result<usize>

Mark tasks left running after a crash as pending / failed retryable again.

Source

pub fn claim_next_chunk_task( &self, run_id: &str, ) -> Result<Option<(i64, String, String)>>

Atomically claim the next pending or retryable failed chunk (single-threaded export).

Source

pub fn claim_next_chunk_task_at_path( db_path: &Path, run_id: &str, ) -> Result<Option<(i64, String, String)>>

Same as claim_next_chunk_task using a fresh connection (parallel workers).

Source

pub fn complete_chunk_task( &self, run_id: &str, chunk_index: i64, rows_written: i64, file_name: Option<&str>, ) -> Result<()>

Source

pub fn fail_chunk_task( &self, run_id: &str, chunk_index: i64, err: &str, ) -> Result<()>

Source

pub fn fail_chunk_task_at_path( db_path: &Path, run_id: &str, chunk_index: i64, err: &str, ) -> Result<()>

Source

pub fn complete_chunk_task_at_path( db_path: &Path, run_id: &str, chunk_index: i64, rows_written: i64, file_name: Option<&str>, ) -> Result<()>

Source

pub fn count_chunk_tasks_not_completed(&self, run_id: &str) -> Result<i64>

Source

pub fn finalize_chunk_run_completed(&self, run_id: &str) -> Result<()>

Source

pub fn reset_chunk_checkpoint(&self, export_name: &str) -> Result<usize>

Remove all chunk runs and tasks for an export (abandon resume).

Source

pub fn get_latest_chunk_run( &self, export_name: &str, ) -> Result<Option<(String, String, String, String)>>

Latest chunk_run row for an export (any status), for rivet state chunks.

Source

pub fn list_chunk_tasks_for_run( &self, run_id: &str, ) -> Result<Vec<ChunkTaskInfo>>

Source

pub fn get(&self, export_name: &str) -> Result<CursorState>

Source

pub fn update(&self, export_name: &str, cursor_value: &str) -> Result<()>

Source

pub fn reset(&self, export_name: &str) -> Result<()>

Source

pub fn list_all(&self) -> Result<Vec<CursorState>>

Source

pub fn record_metric( &self, export_name: &str, run_id: &str, duration_ms: i64, total_rows: i64, peak_rss_mb: Option<i64>, status: &str, error_message: Option<&str>, tuning_profile: Option<&str>, format: Option<&str>, mode: Option<&str>, files_produced: i64, bytes_written: i64, retries: i64, validated: Option<bool>, schema_changed: Option<bool>, ) -> Result<()>

Source

pub fn get_metrics( &self, export_name: Option<&str>, limit: usize, ) -> Result<Vec<ExportMetric>>

Source

pub fn record_file( &self, run_id: &str, export_name: &str, file_name: &str, row_count: i64, bytes: i64, format: &str, compression: Option<&str>, ) -> Result<()>

Source

pub fn get_files( &self, export_name: Option<&str>, limit: usize, ) -> Result<Vec<FileRecord>>

Source

pub fn get_stored_schema( &self, export_name: &str, ) -> Result<Option<Vec<SchemaColumn>>>

Source

pub fn store_schema( &self, export_name: &str, columns: &[SchemaColumn], ) -> Result<()>

Source

pub fn detect_schema_change( &self, export_name: &str, current: &[SchemaColumn], ) -> Result<Option<SchemaChange>>

Source

pub fn open_in_memory() -> Result<Self>

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> MaybeSend for T
where T: Send,