mockforge_chaos/
protocols.rs1pub mod graphql;
4pub mod grpc;
5pub mod websocket;
6
7use crate::{ChaosConfig, Result};
8use async_trait::async_trait;
9
10#[async_trait]
12pub trait ChaosProtocol: Send + Sync {
13 async fn apply_pre_request(&self) -> Result<()>;
15
16 async fn apply_post_response(&self, response_size: usize) -> Result<()>;
18
19 fn should_abort(&self) -> Option<String>;
21
22 fn protocol_name(&self) -> &str;
24}
25
26pub struct ProtocolChaos {
28 config: ChaosConfig,
29}
30
31impl ProtocolChaos {
32 pub fn new(config: ChaosConfig) -> Self {
33 Self { config }
34 }
35
36 pub fn config(&self) -> &ChaosConfig {
37 &self.config
38 }
39
40 pub fn is_enabled(&self) -> bool {
41 self.config.enabled
42 }
43}