Skip to main content

TransferStore

Trait TransferStore 

Source
pub trait TransferStore: Send + Sync {
    // Required methods
    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 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 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 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 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 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 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 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 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 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 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 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;
}
Expand description

Transfer永続化。

実装: super::sqlite::SqliteSyncStore (feature = “sqlite”)

Required Methods§

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一覧。

各file_idの最新Transferのみ返す(古いリトライは除外)。

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別)。

各destについて最新のTransferのみ返す。 FileView構築時にPresenceView導出に使用。

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 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を削除。削除件数を返す。

履歴肥大化防止用。各file_id×destの最新は保持される。

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に遷移。

プロセス再起動時にInFlightのまま残った孤児transferを終端状態にする。 Cancelledは終端状態 — 再実行されない。必要であれば新しいTransferを作成する。 返り値はキャンセルした件数。

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に遷移させる。

Transfer完了時に呼び出し、依存チェーンの次ホップを実行可能にする。 返り値はunblockした件数。

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一覧(最新のみ)。

status() のpending_entries構築用。dest指定なしで全pendingを返す。

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状態の集約統計。

最新Transfer(file_id×dest別)をsrc, dest, state, error_kind, attemptでGROUP BYし、 ファイル数カウントを返す。status()のN+1クエリ問題を解消するための集約メソッド。

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数。

各locationについて、srcとして送出した or completedとして到達したdistinct file数を返す。 UNIONでsrc/completed-destを統合し、同一location×file_idの重複を排除する。

Implementors§