steid

@jamesgill /

steid/src/domain/repository/push_event_repo.rs
Rust1.6 KBCode·Blame·History·Raw
1use super::RepositoryResult;
2use crate::domain::{PushEvent, PushEventId, RepoId};
3
4/// Persistence for [`PushEvent`].
5///
6/// **No delete.** A push event is a record that something happened, and a history that
7/// can be rewritten is not one. Rows go when the repository does, through the foreign
8/// key.
9pub trait PushEventRepository: Send + Sync {
10 fn find(
11 &self,
12 id: &PushEventId,
13 ) -> impl Future<Output = RepositoryResult<Option<PushEvent>>> + Send;
14
15 /// The most recent events for a repository, newest first.
16 ///
17 /// Capped by the caller rather than returning everything: this table only grows,
18 /// and nothing has a use for the whole of it.
19 fn list_by_repo(
20 &self,
21 repo_id: &RepoId,
22 limit: usize,
23 ) -> impl Future<Output = RepositoryResult<Vec<PushEvent>>> + Send;
24
25 /// The most recent events across several repositories at once, newest first.
26 ///
27 /// Takes the repositories rather than an owner, because *which* repositories a
28 /// reader may see is an authorization question and this port answers none: the use
29 /// case filters the listing first and hands over what is left. An empty slice
30 /// answers with an empty list rather than everything, which is the difference
31 /// between an activity feed for someone who may see nothing and one for an
32 /// administrator.
33 fn list_recent(
34 &self,
35 repo_ids: &[RepoId],
36 limit: usize,
37 ) -> impl Future<Output = RepositoryResult<Vec<PushEvent>>> + Send;
38
39 fn save(&self, event: &PushEvent) -> impl Future<Output = RepositoryResult<()>> + Send;
40}