Skip to content

Commit c627647

Browse files
committed
wip
1 parent 8a2692c commit c627647

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

v_exchanges/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ async fn main() {
2020
init_subscriber(None);
2121

2222
let mut client = Client::new();
23-
client.update_default_option(BinanceOption::HttpUrl(BinanceHttpUrl::Spot));
23+
client.update_default_option(BinanceOption::HttpUrl(BinanceHttpUrl::FuturesUsdM));
2424

2525
#[derive(Serialize)]
2626
pub struct KlineParams<'a> {
@@ -45,7 +45,7 @@ async fn main() {
4545
}
4646
}
4747

48-
let klines: Vec<KlineCore> = client.get("/fapi/v1/klines", Some(&KlineParams::default()), [BinanceOption::Default]).await.unwrap();
48+
let klines: Vec<KlineCore> = client.get(/*https://fapi.binance.com*/"/fapi/v1/klines", Some(&KlineParams::default()), [BinanceOption::Default]).await.unwrap();
4949

5050
dbg!(&klines);
5151
}

v_exchanges_api_generics/src/http.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pub use reqwest::{
77
};
88
use serde::Serialize;
99
use thiserror::Error;
10-
use tracing::instrument;
10+
use tracing::{debug, instrument};
1111

1212
/// The User Agent string
1313
pub static USER_AGENT: &str = concat!("v_exchanges_api_generics/", env!("CARGO_PKG_VERSION"));
@@ -34,7 +34,7 @@ impl Client {
3434
///
3535
/// The request is passed to `handler` before being sent, and the response is passed to `handler` before being returned.
3636
/// Note, that as stated in the docs for [RequestBuilder::query()], parameter `query` only accepts a **sequence of** key-value pairs.
37-
//#[instrument] //TODO: get all generics to impl std::fmt::Debug
37+
#[instrument(skip_all, fields(?url))] //TODO: get all generics to impl std::fmt::Debug
3838
pub async fn request<Q, B, H>(&self, method: Method, url: &str, query: Option<&Q>, body: Option<B>, handler: &H) -> Result<H::Successful, RequestError<H::BuildError, H::Unsuccessful>>
3939
where
4040
Q: Serialize + ?Sized,
@@ -56,11 +56,11 @@ impl Client {
5656
let status = response.status();
5757
let headers = std::mem::take(response.headers_mut());
5858
let body = response.bytes().await.map_err(RequestError::ReceiveResponse)?;
59+
//TODO!!!: we are only retrying when response is not received. Although there is a list of errors we would also like to retry on.
60+
debug!(?body);
5961
return handler.handle_response(status, headers, body).map_err(RequestError::ResponseHandleError);
6062
}
6163
Err(error) => {
62-
//TODO!!!!: we are retrying regardless of the error. Must refactor to require a list of retryable errors for each defined exchange.
63-
dbg!(&error);
6464
if i < config.max_try {
6565
tracing::warn!("Retrying sending request; made so far: {i}");
6666
tokio::time::sleep(config.retry_cooldown).await;

0 commit comments

Comments
 (0)