pub mod graphql;
pub mod grpc;
pub mod websocket;
use crate::{ChaosConfig, Result};
use async_trait::async_trait;
#[async_trait]
pub trait ChaosProtocol: Send + Sync {
async fn apply_pre_request(&self) -> Result<()>;
async fn apply_post_response(&self, response_size: usize) -> Result<()>;
fn should_abort(&self) -> Option<String>;
fn protocol_name(&self) -> &str;
}
pub struct ProtocolChaos {
config: ChaosConfig,
}
impl ProtocolChaos {
pub fn new(config: ChaosConfig) -> Self {
Self { config }
}
pub fn config(&self) -> &ChaosConfig {
&self.config
}
pub fn is_enabled(&self) -> bool {
self.config.enabled
}
}