From 4c06bdb6d2ce2bc5f8f85cced0e58b9bb3f9e3f8 Mon Sep 17 00:00:00 2001 From: Warittorn Cheevachaipimol Date: Mon, 12 Feb 2024 15:42:07 +0700 Subject: [PATCH] cleanup --- bothan-binance/src/service.rs | 6 ++---- bothan-binance/src/types.rs | 5 +++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/bothan-binance/src/service.rs b/bothan-binance/src/service.rs index 063631df..5e5f1b53 100644 --- a/bothan-binance/src/service.rs +++ b/bothan-binance/src/service.rs @@ -11,9 +11,7 @@ use crate::api::types::{BinanceResponse, Data}; use crate::api::websocket::BinanceWebsocket; use crate::cache::{Cache, Error as CacheError}; use crate::error::Error; -use crate::types::{Command, PriceData}; - -pub const DEFAULT_CHANNEL_SIZE: usize = 100; +use crate::types::{Command, PriceData, DEFAULT_CHANNEL_SIZE, DEFAULT_TIMEOUT}; pub struct BinanceService { cache: Arc, @@ -106,7 +104,7 @@ fn start_service( process_command(&cmd, &mut ws, &cache).await; }, // MOVE TIMEOUT to default config - result = timeout(Duration::new(360, 0), ws.next()) => { + result = timeout(DEFAULT_TIMEOUT, ws.next()) => { match &result { Ok(Ok(result)) => { process_response(result, &cache).await; diff --git a/bothan-binance/src/types.rs b/bothan-binance/src/types.rs index 1811d03a..562fff8c 100644 --- a/bothan-binance/src/types.rs +++ b/bothan-binance/src/types.rs @@ -1,6 +1,11 @@ +use std::time::Duration; + use derive_more::Display; use serde::Deserialize; +pub const DEFAULT_CHANNEL_SIZE: usize = 100; +pub const DEFAULT_TIMEOUT: Duration = Duration::from_secs(720); + #[derive(Clone, Debug, Deserialize, Display)] #[display("id: {}, price: {}, timestamp: {}", id, price, timestamp)] pub struct PriceData {