pdc_core/generator/
mod.rs

1use crate::scenario::Scenario;
2use crossbeam_channel::Receiver;
3
4pub mod fuzzy_request_generator;
5pub mod hyper;
6pub mod reqwest_generator;
7
8/// Traffic Generators are the bread and butter of pdc.
9/// Structs that implement TrafficGenerator will take in
10/// a scenario and try to replicate the network traffic
11/// described by that scenario.
12pub trait TrafficGenerator<T: Scenario>: Send + Sync {
13    /// Give a bounded channel that sends time series data on the send rate of
14    /// a generator. The data is encoded as
15    /// `(Miliseconds since start of scenario, counts/sec)`.
16    fn get_data_rate_channel(&self) -> Receiver<(f32, f32)>;
17    /// Give a bounded channel that sends the total amount of packets/requests sent
18    fn get_sent_packets_channel(&self) -> Receiver<usize>;
19    /// Give a bounded channel that sends time series data on the send rate of
20    /// a generator. The data is encoded as
21    /// `(Miliseconds since start of scenario, counts/sec)`.
22    fn get_error_rate_channel(&self) -> Receiver<(f32, f32)>;
23    /// Send a single packet per call, used for debuging and low traffic testing.
24    fn send_packet(&mut self);
25    /// Sets a [`Scenario`] for the generator to try and replicate.
26    fn set_scenario(&mut self, schem: T);
27    /// Gets the current [`Scenario`]
28    fn get_scenario(&self) -> &T;
29    /// Runs the current scenario
30    fn run_scenario(&mut self);
31    /// Run the generator at full throttle!
32    fn fire_hose(&mut self);
33}
34
35#[derive(Clone, Debug)]
36pub struct HttpConfig {
37    pub url: String,
38    /// HTTP Method, Defaults to GET.
39    pub method: String,
40    pub body: String,
41}