Skip to main content

run_broadcast

Function run_broadcast 

Source
pub(crate) async fn run_broadcast<R, D, Fut>(
    targets: Vec<String>,
    body: &str,
    msg_id: &str,
    concurrency: usize,
    resolve: R,
    deliver: D,
) -> Vec<BroadcastOutcome>
where R: Fn(&str) -> Option<String>, D: Fn(String, String, TurnOrigin) -> Fut, Fut: Future<Output = Result<(), String>>,
Expand description

The broadcast logic, with srv’s two touch points passed in so it can be tested without an AppState: resolve maps a block id to its agent id, and deliver starts one turn (block id, full text, origin).

Targets are resolved first so RECIPIENTS in every header counts the agents actually addressed; the same msg_id ties the copies together in the audit log. Turns start up to concurrency at a time, and results come back in the order of targets.