Skip to main content

amts_prelude/
messages.rs

1use serde::{Deserialize, Serialize};
2use uuid::Uuid;
3
4type Payload = Vec<u8>;
5
6///Command messages allowed to be sent over the wire
7#[derive(Debug, Clone, Serialize, Deserialize)]
8pub struct CommandMessage<C> {
9    pub id: Uuid,
10    pub command: C,
11    pub payload: Option<Payload>,
12}
13
14///Messages that are allowed to be received over the wire
15#[derive(Debug, Clone, Serialize, Deserialize)]
16pub struct ResponseMessage<C> {
17    pub id: Uuid,
18    pub command: C,
19    pub payload: Option<Payload>,
20    pub success: bool,
21}
22
23///Instruction type
24#[derive(Debug, Clone, Serialize, Deserialize)]
25pub struct Instruction<A, C> {
26    pub id: Uuid,
27    pub action: A,
28    pub compensate: C,
29    pub response_data_key: u32,
30    pub response_instert_key: u32,
31}
32
33///A vector of instructions for the saga
34#[derive(Debug, Clone, Serialize, Deserialize)]
35pub struct Saga<A, C> {
36    pub id: Uuid,
37    pub initial_payload: Option<Payload>,
38    pub instructions: Vec<Instruction<A, C>>,
39}