pub enum AggregationStatus<Aggregated> {
Ignore,
Aggregated(Aggregated),
}
#[macro_export]
macro_rules! aggregate {
(
state=$state:ident, channel=$channel:ident, msg=$msg:ident,
aggregate=$aggregate:path,
accept_failure=$accept_failure:path,
output_queue=$output_queue:expr,
exchange=$exchange:expr $(,)?
) => {
match $aggregate($state, &$msg).await {
Err(user_error) => {
warn!(
"failed to merge messages for {:?}, error is: {}, will be retried",
&$msg, user_error
);
Ok(Responsibility::Reject)
}
Ok(AggregationStatus::Ignore) => {
Ok(Responsibility::Accept)
}
Ok(AggregationStatus::Aggregated(merged_msg)) => {
$crate::maybe_send_to_next!(
&merged_msg,
$output_queue,
$channel,
$msg.into(),
$accept_failure,
$exchange,
)
}
}
};
}