commit_bridge/repository/
trigger.rs1use crate::model::TriggerQueueItem;
4use crate::repository::RepositoryError;
5use async_trait::async_trait;
6
7#[derive(Debug, Clone)]
9pub struct UpdateRetryStatus {
10 pub id: i64,
12
13 pub retry_count: i64,
15
16 pub max_attempts: u32,
18
19 pub backoff_base_secs: u64,
21}
22
23#[async_trait]
25pub trait TriggerRepository: Send + Sync {
26 async fn get_all(&self) -> Result<Vec<TriggerQueueItem>, RepositoryError>;
28
29 async fn find_oldest_pending_and_mark_processing(
31 &self,
32 ) -> Result<Option<TriggerQueueItem>, RepositoryError>;
33
34 async fn update_retry_status(&self, params: UpdateRetryStatus) -> Result<(), RepositoryError>;
36
37 async fn recover_stuck_tasks(&self, threshold_seconds: u64) -> Result<(), RepositoryError>;
39
40 async fn delete_by_id(&self, id: i64) -> Result<(), RepositoryError>;
42
43 async fn queue_triggers_for_branch(
45 &self,
46 branch_id: i64,
47 new_hash: &crate::domain::CommitHash,
48 executor: &mut sqlx::SqliteConnection,
49 ) -> Result<(), RepositoryError>;
50}