derive_deftly::define_derive_deftly! {
export CircuitReactor expect items:
impl<$tgens> $ttype where
$twheres
{
pub(crate) async fn run(mut self) -> $crate::Result<()> {
let unique_id = self.unique_id;
tracing::debug!(
circ_id = %unique_id,
"Running {}", ${tmeta(reactor_name) as str}
);
let result: $crate::Result<()> = loop {
match ${tmeta(run_inner_fn) as expr}(&mut self).await {
Ok(()) => {
${if tmeta(only_run_once) {
break Ok(());
}}
},
Err(ReactorError::Shutdown) => break Ok(()),
Err(ReactorError::Err(e)) => break Err(e),
}
};
let msg = format!("{} shut down", ${tmeta(reactor_name) as str});
match &result {
Ok(()) => tracing::trace!(circ_id = %unique_id, "{msg}"),
Err(e) => tor_error::debug_report!(e, circ_id = %unique_id, "{msg}"),
}
result
}
}
}
pub(crate) use derive_deftly_template_CircuitReactor;