#[path = "shared.rs"]
mod shared;
use std::time::Duration;
use wingfoil::adapters::iceoryx2::iceoryx2_pub;
use wingfoil::*;
use shared::{Quote, QuoteLatency, SERVICE_NAME, quote_latency};
fn main() {
env_logger::init();
let period = Duration::from_millis(100);
let stream = ticker(period)
.count()
.map(|seq: u64| {
Traced::<Quote, QuoteLatency>::new(Quote {
seq,
price: 100.0 + (seq as f64) * 0.01,
})
})
.stamp::<quote_latency::produce>()
.stamp::<quote_latency::publish>();
let burst_stream = stream.map(|t| {
let mut b = Burst::default();
b.push(t);
b
});
let pub_node = iceoryx2_pub(burst_stream, SERVICE_NAME);
println!(
"Publishing Traced<Quote, QuoteLatency> on \"{SERVICE_NAME}\" every {period:?} \
— press Ctrl-C to stop"
);
Graph::new(vec![pub_node], RunMode::RealTime, RunFor::Forever)
.run()
.unwrap();
}