mirror of
https://git.joinplu.me/Plume/Plume.git
synced 2024-11-22 11:31:01 +00:00
Merge pull request 'Sleep between broadcasting' (#1071) from sleep-broadcasting into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/1071
This commit is contained in:
commit
c32acb2fcf
1 changed files with 7 additions and 1 deletions
|
@ -8,7 +8,10 @@ use rocket::{
|
||||||
response::{Responder, Response},
|
response::{Responder, Response},
|
||||||
Outcome,
|
Outcome,
|
||||||
};
|
};
|
||||||
use tokio::runtime;
|
use tokio::{
|
||||||
|
runtime,
|
||||||
|
time::{sleep, Duration},
|
||||||
|
};
|
||||||
use tracing::{debug, warn};
|
use tracing::{debug, warn};
|
||||||
|
|
||||||
use self::sign::Signable;
|
use self::sign::Signable;
|
||||||
|
@ -156,6 +159,9 @@ where
|
||||||
let rx = rx.clone();
|
let rx = rx.clone();
|
||||||
let handle = rt.spawn(async move {
|
let handle = rt.spawn(async move {
|
||||||
while let Ok(request_builder) = rx.recv_async().await {
|
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
|
let _ = request_builder
|
||||||
.send()
|
.send()
|
||||||
.await
|
.await
|
||||||
|
|
Loading…
Reference in a new issue