steid

@jamesgill /

steid/src/domain/repository/webhook_delivery_repo.rs
Rust1.0 KBCode·Blame·History·Raw
1use super::RepositoryResult;
2use crate::domain::{WebhookDelivery, WebhookId};
3
4/// Persistence for [`WebhookDelivery`].
5///
6/// Append-only from the application's side: an attempt happened, and later attempts are
7/// new rows rather than edits to an old one.
8pub trait WebhookDeliveryRepository: Send + Sync {
9 /// The most recent attempts against a hook, newest first.
10 fn list_by_webhook(
11 &self,
12 webhook_id: &WebhookId,
13 limit: usize,
14 ) -> impl Future<Output = RepositoryResult<Vec<WebhookDelivery>>> + Send;
15
16 /// The single most recent attempt, for the status dot on a hook list.
17 ///
18 /// Asked for separately rather than taking the head of `list_by_webhook`, because a
19 /// list page asks it once per hook and wants one row back each time.
20 fn latest_by_webhook(
21 &self,
22 webhook_id: &WebhookId,
23 ) -> impl Future<Output = RepositoryResult<Option<WebhookDelivery>>> + Send;
24
25 fn save(&self, delivery: &WebhookDelivery)
26 -> impl Future<Output = RepositoryResult<()>> + Send;
27}