From 4d3db9af737801c67b0cd332ac291472e096ea61 Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Sat, 7 May 2022 04:50:58 +0900 Subject: [PATCH] Sleep between broadcasting --- plume-common/src/activity_pub/mod.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plume-common/src/activity_pub/mod.rs b/plume-common/src/activity_pub/mod.rs index ba73ab19..74fb1300 100644 --- a/plume-common/src/activity_pub/mod.rs +++ b/plume-common/src/activity_pub/mod.rs @@ -8,7 +8,10 @@ use rocket::{ response::{Responder, Response}, Outcome, }; -use tokio::runtime; +use tokio::{ + runtime, + time::{sleep, Duration}, +}; use tracing::{debug, warn}; use self::sign::Signable; @@ -156,6 +159,9 @@ where let rx = rx.clone(); let handle = rt.spawn(async move { while let Ok(request_builder) = rx.recv_async().await { + // After broadcasting, target instance sends request to this instance. + // Sleep here in order to reduce requests at once + sleep(Duration::from_millis(500)).await; let _ = request_builder .send() .await