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
impl SqliteSyncStore
Sourcepub async fn insert_task(&self, id: &TaskId) -> Result<(), InfraError>
pub async fn insert_task(&self, id: &TaskId) -> Result<(), InfraError>
Insert a new task as Pending.
Sourcepub async fn update_task_running(
&self,
id: &TaskId,
phase: &str,
) -> Result<(), InfraError>
pub async fn update_task_running( &self, id: &TaskId, phase: &str, ) -> Result<(), InfraError>
Update task status to Running with a phase description.
Sourcepub async fn update_task_completed(
&self,
id: &TaskId,
report: &SyncReport,
) -> Result<(), InfraError>
pub async fn update_task_completed( &self, id: &TaskId, report: &SyncReport, ) -> Result<(), InfraError>
Update task status to Completed with a serialized SyncReport.
Sourcepub async fn update_task_failed(
&self,
id: &TaskId,
error: &str,
) -> Result<(), InfraError>
pub async fn update_task_failed( &self, id: &TaskId, error: &str, ) -> Result<(), InfraError>
Update task status to Failed with an error message.
Sourcepub async fn load_task(
&self,
id: &TaskId,
) -> Result<Option<TaskStatus<SyncReport>>, InfraError>
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.
Sourcepub async fn recover_stale_running(&self) -> Result<usize, InfraError>
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
impl SqliteSyncStore
Sourcepub async fn open(path: &Path) -> Result<Self, InfraError>
pub async fn open(path: &Path) -> Result<Self, InfraError>
Open (or create) a sync database at the given path.
Sourcepub async fn open_in_memory() -> Result<Self, InfraError>
pub async fn open_in_memory() -> Result<Self, InfraError>
Open an in-memory database (for testing).
Trait Implementations§
Source§impl LocationFileStore for SqliteSyncStore
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,
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,
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,
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,
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,
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,
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,
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
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,
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,
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,
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,
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,
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,
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,
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,
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§impl TransferStore for SqliteSyncStore
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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§
impl Freeze for SqliteSyncStore
impl RefUnwindSafe for SqliteSyncStore
impl Send for SqliteSyncStore
impl Sync for SqliteSyncStore
impl Unpin for SqliteSyncStore
impl UnsafeUnpin for SqliteSyncStore
impl UnwindSafe for SqliteSyncStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more