From 9e1e2ad1f5bdf6e3e75ace911b7f0294d9cec3c4 Mon Sep 17 00:00:00 2001 From: Katalina Okano Date: Mon, 28 Nov 2022 00:28:29 -0500 Subject: [PATCH] revert: add a long heartbeat for slower listeners --- services/websocket/src/main.rs | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/services/websocket/src/main.rs b/services/websocket/src/main.rs index 69b5982..06e355f 100644 --- a/services/websocket/src/main.rs +++ b/services/websocket/src/main.rs @@ -242,17 +242,23 @@ struct Payload { payload: Event, } -/// Send a longer heartbeat in case this is PS4EU and gets like one event per hour -async fn heartbeat() { - let mut interval = tokio::time::interval(Duration::from_secs(150)); - loop { - interval.tick().await; - let mut con = REDIS_CLIENT.get_connection().unwrap(); - let role: String = ROLE.parse().unwrap(); - let heartbeat_key = format!("heartbeat:{}:{}", PAIR.to_string(), role); - let _: () = con.set_ex(heartbeat_key, "1", 300).unwrap(); - } -} +// /// Send a longer heartbeat in case this is PS4EU and gets like one event per hour +// async fn heartbeat() { +// let mut interval = tokio::time::interval(Duration::from_secs(150)); +// loop { +// interval.tick().await; +// let mut con = REDIS_CLIENT.get_connection().unwrap(); +// let role: String = ROLE.parse().unwrap(); +// let heartbeat_key = format!("heartbeat:{}:{}", PAIR.to_string(), role); +// let response: Option = con.get(heartbeat_key.clone()).unwrap(); +// match response { +// None => { +// let _: () = con.set_ex(heartbeat_key, "1", 300).unwrap(); +// } +// _ => (), +// } +// } +// } #[tokio::main] async fn main() { @@ -305,7 +311,7 @@ async fn main() { _ = fused_writer => {} } - tokio::spawn(heartbeat()); + // tokio::spawn(heartbeat()); init.await.unwrap(); }