From c30cfbf0522f2d36ed430d3cb0cbb0a202c47ac2 Mon Sep 17 00:00:00 2001 From: Nicolas Rybowski Date: Thu, 31 Oct 2024 17:13:25 +0100 Subject: [PATCH] bier: Batch BIFT entries addition Signed-off-by: Nicolas Rybowski --- holo-utils/src/bier.rs | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/holo-utils/src/bier.rs b/holo-utils/src/bier.rs index 5b6149c7..5b1d8a0f 100644 --- a/holo-utils/src/bier.rs +++ b/holo-utils/src/bier.rs @@ -50,21 +50,18 @@ pub async fn bift_sync_fastclick(bift: &Bift) { .collect::>() .join(","); - // TODO: Batch route addition when multiple BfrIds have the same F-BM - for (id, prefix) in ids { - let body = format!( - "{:#?} {:#?} {} {:#?} {} {}", - id, prefix, bs, nbr, idx, name - ); - // TODO: Use gRPC rather than plain HTTP - let client = reqwest::Client::new(); - let _res = client - // TODO: Make Fastclick BIFT URI configurable through YANG model - .post("http://127.0.0.1/bift0/add") - .body(body.clone()) - .send() - .await; - } + // Batching BFRs having the same FBM + let bfrs = ids.iter().map(|(id, prefix)| format!("{:#?}_{:#?}", id, prefix)).collect::>().join(","); + let body = format!("{} {:#?} {} {} {}", bs, nbr, idx, name, bfrs); + + // TODO: Use gRPC rather than plain HTTP + let client = reqwest::Client::new(); + let _res = client + // TODO: Make Fastclick BIFT URI configurable through YANG model + .post("http://127.0.0.1/bift0/add") + .body(body) + .send() + .await; } }