g1t/crates/contracts/src/events.rs

45 lines1,187 bytesCodeBlame
1//! Events published on the bus. Mirrors `packages/contracts/src/events.ts`.
2
3use serde::Serialize;
4
5/// What a publisher supplies; the bus fills in the id and time.
6#[derive(Debug, Serialize)]
7#[serde(rename_all = "camelCase")]
8pub struct NewEvent<T: Serialize> {
9 #[serde(rename = "type")]
10 pub kind: &'static str,
11 /// The service that published it.
12 pub source: &'static str,
13 /// The repo the event concerns.
14 pub repo_id: Option<String>,
15 /// The user or agent that caused it, if any.
16 pub actor: Option<String>,
17 pub data: T,
18}
19
20#[derive(Debug, Serialize)]
21#[serde(rename_all = "camelCase")]
22pub struct RepoCreated {
23 pub repo_id: String,
24 pub namespace: String,
25 pub name: String,
26 pub is_private: bool,
27}
28
29#[derive(Debug, Serialize)]
30#[serde(rename_all = "camelCase")]
31pub struct RepoForked {
32 pub repo_id: String,
33 pub source_repo_id: String,
34 pub attempt_id: String,
35}
36
37/// `after` is the commit the ref points to once the push has landed.
38#[derive(Debug, Serialize)]
39#[serde(rename_all = "camelCase")]
40pub struct GitPush {
41 pub repo_id: String,
42 #[serde(rename = "ref")]
43 pub git_ref: String,
44 pub after: String,
45}