as shown here making a whole request can sometimes be a bit convoluted. the Distributor::request() function aims to be syntactic sugar to wrap this.
let answer = probes
.ask_one(url.clone())
.expect("couldn't send message to probes");
// Handle a reply
MessageHandler::new(answer.await.expect("couldn't get an answer")).on_tell(
|probe_result: ProbeRunStatus, _| {
info!("probe is done: {:?}", probe_result);
},
);
will then become
let probe_run_status: Result<ProbeRunStatus, SendError> = probes
.request(url.clone())
.await
.expect("couldn't receive reply");
info!("probe is done: {:?}", probe_result);
It uses a channel() behind the scene, as shown in the signature:
Proposal: Distributor request fn.
as shown here making a whole request can sometimes be a bit convoluted. the
Distributor::request()
function aims to be syntactic sugar to wrap this.will then become
It uses a channel() behind the scene, as shown in the signature:
Here's what the documentation looks like so far:
there's also a request_sync variant which is backed by a mpsc::channel(), and can be called like this:
Checklist
cargo test
.