Skip to main content

SqliteSyncStore

Struct SqliteSyncStore 

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

SQLite-backed sync store.

Uses tokio_rusqlite::Connection — a handle that dispatches closures to a dedicated background thread via mpsc channel. Does not block the async runtime.

Implementations§

Source§

impl SqliteSyncStore

Source

pub async fn insert_task(&self, id: &TaskId) -> Result<(), InfraError>

Insert a new task as Pending.

Source

pub async fn update_task_running( &self, id: &TaskId, phase: &str, ) -> Result<(), InfraError>

Update task status to Running with a phase description.

Source

pub async fn update_task_completed( &self, id: &TaskId, report: &SyncReport, ) -> Result<(), InfraError>

Update task status to Completed with a serialized SyncReport.

Source

pub async fn update_task_failed( &self, id: &TaskId, error: &str, ) -> Result<(), InfraError>

Update task status to Failed with an error message.

Source

pub async fn load_task( &self, id: &TaskId, ) -> Result<Option<TaskStatus<SyncReport>>, InfraError>

Load task status from DB. Returns None if task_id is unknown.

Source

pub async fn recover_stale_running(&self) -> Result<usize, InfraError>

On startup, mark all running tasks as failed.

If a task was running when the process terminated, it will never reach Completed/Failed. This recovers those zombie tasks.

Source§

impl SqliteSyncStore

Source

pub async fn open(path: &Path) -> Result<Self, InfraError>

Open (or create) a sync database at the given path.

Source

pub async fn open_in_memory() -> Result<Self, InfraError>

Open an in-memory database (for testing).

Trait Implementations§

Source§

impl LocationFileStore for SqliteSyncStore

Source§

fn upsert<'life0, 'life1, 'async_trait>( &'life0 self, file: &'life1 LocationFile, ) -> Pin<Box<dyn Future<Output = Result<(), InfraError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

LocationFileを保存(新規 or 更新)。 Read more
Source§

fn get<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, file_id: &'life1 str, location_id: &'life2 LocationId, ) -> Pin<Box<dyn Future<Output = Result<Option<LocationFile>, InfraError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

(file_id, location_id) でLocationFileを取得。
Source§

fn list_by_file<'life0, 'life1, 'async_trait>( &'life0 self, file_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<LocationFile>, InfraError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

あるファイルの全Location分のLocationFileを取得。 Read more
Source§

fn list_by_location<'life0, 'life1, 'async_trait>( &'life0 self, location_id: &'life1 LocationId, ) -> Pin<Box<dyn Future<Output = Result<Vec<LocationFile>, InfraError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

あるLocationの全LocationFileを取得。 Read more
Source§

fn list_by_files<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, file_ids: &'life1 [&'life2 str], ) -> Pin<Box<dyn Future<Output = Result<HashMap<String, Vec<LocationFile>>, InfraError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

複数ファイルの全LocationFileを一括取得。 Read more
Source§

fn delete<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, file_id: &'life1 str, location_id: &'life2 LocationId, ) -> Pin<Box<dyn Future<Output = Result<bool, InfraError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

LocationFileを削除。削除した場合true。
Source§

fn count_by_location<'life0, 'life1, 'async_trait>( &'life0 self, location_id: &'life1 LocationId, ) -> Pin<Box<dyn Future<Output = Result<usize, InfraError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

あるLocationのLocationFile数。
Source§

impl TopologyFileStore for SqliteSyncStore

Source§

fn upsert<'life0, 'life1, 'async_trait>( &'life0 self, file: &'life1 TopologyFile, ) -> Pin<Box<dyn Future<Output = Result<(), InfraError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

TopologyFileを保存(新規 or 更新)。 Read more
Source§

fn get_by_id<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<TopologyFile>, InfraError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

IDでTopologyFileを取得。
Source§

fn get_by_path<'life0, 'life1, 'async_trait>( &'life0 self, relative_path: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<TopologyFile>, InfraError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

relative_pathでTopologyFileを取得(deleted除外)。
Source§

fn find_by_canonical_hash<'life0, 'life1, 'async_trait>( &'life0 self, hash: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<TopologyFile>, InfraError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

canonical_hashでTopologyFileを検索(deleted除外)。 Read more
Source§

fn list_active<'life0, 'async_trait>( &'life0 self, file_type: Option<FileType>, limit: Option<usize>, ) -> Pin<Box<dyn Future<Output = Result<Vec<TopologyFile>, InfraError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

生存中(deleted_at IS NULL)のTopologyFile一覧。
Source§

fn list_deleted<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<TopologyFile>, InfraError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

削除済み(deleted_at IS NOT NULL)のTopologyFile一覧。 Read more
Source§

fn hard_delete<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<bool, InfraError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

削除済みTFを物理削除。 Read more
Source§

fn count_active<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<usize, InfraError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

生存中ファイル数。
Source§

fn list_active_paths<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<String>, InfraError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

全TopologyFileのrelative_path一覧(deleted除外)。 Read more
Source§

impl TransferStore for SqliteSyncStore

Source§

fn insert_transfer<'life0, 'life1, 'async_trait>( &'life0 self, transfer: &'life1 Transfer, ) -> Pin<Box<dyn Future<Output = Result<(), InfraError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Transferを保存。
Source§

fn update_transfer<'life0, 'life1, 'async_trait>( &'life0 self, transfer: &'life1 Transfer, ) -> Pin<Box<dyn Future<Output = Result<(), InfraError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Transfer状態を更新(start/complete/fail後に呼ぶ)。
Source§

fn queued_transfers<'life0, 'life1, 'async_trait>( &'life0 self, dest: &'life1 LocationId, ) -> Pin<Box<dyn Future<Output = Result<Vec<Transfer>, InfraError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

特定destのQueued Transfer一覧。 Read more
Source§

fn latest_transfers_by_file<'life0, 'life1, 'async_trait>( &'life0 self, file_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<Transfer>, InfraError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

特定ファイルの最新Transfer(dest別)。 Read more
Source§

fn failed_transfers<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<Transfer>, InfraError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Failed Transfer一覧(最新のみ)。
Source§

fn all_pending_transfers<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<Transfer>, InfraError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

全destのQueued/Blocked Transfer一覧(最新のみ)。 Read more
Source§

fn transfer_stats<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<TransferStatRow>, InfraError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Transfer状態の集約統計。 Read more
Source§

fn present_counts_by_location<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<HashMap<LocationId, usize>, InfraError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Location別のPresent file数。 Read more
Source§

fn prune_completed<'life0, 'async_trait>( &'life0 self, before: DateTime<Utc>, ) -> Pin<Box<dyn Future<Output = Result<usize, InfraError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

完了済み古いTransferを削除。削除件数を返す。 Read more
Source§

fn count_queued<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<usize, InfraError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Queued状態のTransfer件数を返す。進捗表示用。
Source§

fn cancel_orphaned_inflight<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<usize, InfraError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

InFlight状態のTransferをCancelledに遷移。 Read more
Source§

fn unblock_dependents<'life0, 'life1, 'async_trait>( &'life0 self, completed_transfer_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<usize, InfraError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

指定Transfer IDに依存するBlocked TransferをQueuedに遷移させる。 Read more

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, 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<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