use crate::model::TriggerQueueItem;
use crate::repository::RepositoryError;
use async_trait::async_trait;
#[derive(Debug, Clone)]
pub struct UpdateRetryStatus {
pub id: i64,
pub retry_count: i64,
pub max_attempts: u32,
pub backoff_base_secs: u64,
}
#[async_trait]
pub trait TriggerRepository: Send + Sync {
async fn get_all(&self) -> Result<Vec<TriggerQueueItem>, RepositoryError>;
async fn find_oldest_pending_and_mark_processing(
&self,
) -> Result<Option<TriggerQueueItem>, RepositoryError>;
async fn update_retry_status(&self, params: UpdateRetryStatus) -> Result<(), RepositoryError>;
async fn recover_stuck_tasks(&self, threshold_seconds: u64) -> Result<(), RepositoryError>;
async fn delete_by_id(&self, id: i64) -> Result<(), RepositoryError>;
async fn queue_triggers_for_branch(
&self,
branch_id: i64,
new_hash: &crate::domain::CommitHash,
executor: &mut sqlx::SqliteConnection,
) -> Result<(), RepositoryError>;
}