use super::tracer::Tracer;
use meio::{Action, ActionHandler, Actor, Context};
use rill_protocol::flow::core::{ActionEnvelope, Flow};
pub struct TracerAction<T: Flow, Tag = ()> {
pub envelope: ActionEnvelope<T>,
pub tag: Tag,
}
impl<T: Flow, Tag: Send + 'static> Action for TracerAction<T, Tag> {}
impl<T: Flow> Tracer<T> {
pub fn forward<A: Actor, Tag>(&self, tag: Tag, ctx: &mut Context<A>)
where
A: ActionHandler<TracerAction<T, Tag>>,
Tag: Clone + Send + Sync + 'static,
{
let addr = ctx.address().clone();
self.async_callback(move |envelope| {
let mut addr = addr.clone();
let tag = tag.clone();
async move {
let msg = TracerAction { envelope, tag };
addr.act(msg).await
}
});
}
}