Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
warittornc committed Feb 12, 2024
1 parent 6143cbc commit 4c06bdb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 2 additions & 4 deletions bothan-binance/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Cache>,
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions bothan-binance/src/types.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down

0 comments on commit 4c06bdb

Please sign in to comment.