Update reqwest

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2024-03-20 20:00:35 +00:00
parent 2ad42c5462
commit 46508d1b4f
5 changed files with 38 additions and 45 deletions

61
Cargo.lock generated
View File

@@ -254,7 +254,7 @@ dependencies = [
"clickhouse-rs-cityhash-sys", "clickhouse-rs-cityhash-sys",
"futures", "futures",
"hyper 0.14.28", "hyper 0.14.28",
"hyper-tls", "hyper-tls 0.5.0",
"lz4", "lz4",
"sealed", "sealed",
"serde", "serde",
@@ -636,25 +636,6 @@ dependencies = [
"spinning_top", "spinning_top",
] ]
[[package]]
name = "h2"
version = "0.3.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fbd2820c5e49886948654ab546d0688ff24530286bdcf8fca3cefb16d4618eb"
dependencies = [
"bytes",
"fnv",
"futures-core",
"futures-sink",
"futures-util",
"http 0.2.12",
"indexmap 2.2.5",
"slab",
"tokio",
"tokio-util",
"tracing",
]
[[package]] [[package]]
name = "h2" name = "h2"
version = "0.4.3" version = "0.4.3"
@@ -791,7 +772,6 @@ dependencies = [
"futures-channel", "futures-channel",
"futures-core", "futures-core",
"futures-util", "futures-util",
"h2 0.3.25",
"http 0.2.12", "http 0.2.12",
"http-body 0.4.6", "http-body 0.4.6",
"httparse", "httparse",
@@ -814,7 +794,7 @@ dependencies = [
"bytes", "bytes",
"futures-channel", "futures-channel",
"futures-util", "futures-util",
"h2 0.4.3", "h2",
"http 1.1.0", "http 1.1.0",
"http-body 1.0.0", "http-body 1.0.0",
"httparse", "httparse",
@@ -823,6 +803,7 @@ dependencies = [
"pin-project-lite", "pin-project-lite",
"smallvec", "smallvec",
"tokio", "tokio",
"want",
] ]
[[package]] [[package]]
@@ -838,6 +819,22 @@ dependencies = [
"tokio-native-tls", "tokio-native-tls",
] ]
[[package]]
name = "hyper-tls"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0"
dependencies = [
"bytes",
"http-body-util",
"hyper 1.2.0",
"hyper-util",
"native-tls",
"tokio",
"tokio-native-tls",
"tower-service",
]
[[package]] [[package]]
name = "hyper-util" name = "hyper-util"
version = "0.1.3" version = "0.1.3"
@@ -845,6 +842,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca38ef113da30126bbff9cd1705f9273e15d45498615d138b0c20279ac7a76aa" checksum = "ca38ef113da30126bbff9cd1705f9273e15d45498615d138b0c20279ac7a76aa"
dependencies = [ dependencies = [
"bytes", "bytes",
"futures-channel",
"futures-util", "futures-util",
"http 1.1.0", "http 1.1.0",
"http-body 1.0.0", "http-body 1.0.0",
@@ -852,6 +850,9 @@ dependencies = [
"pin-project-lite", "pin-project-lite",
"socket2", "socket2",
"tokio", "tokio",
"tower",
"tower-service",
"tracing",
] ]
[[package]] [[package]]
@@ -1453,20 +1454,22 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f"
[[package]] [[package]]
name = "reqwest" name = "reqwest"
version = "0.11.27" version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" checksum = "58b48d98d932f4ee75e541614d32a7f44c889b72bd9c2e04d95edd135989df88"
dependencies = [ dependencies = [
"base64", "base64",
"bytes", "bytes",
"encoding_rs", "encoding_rs",
"futures-core", "futures-core",
"futures-util", "futures-util",
"h2 0.3.25", "h2",
"http 0.2.12", "http 1.1.0",
"http-body 0.4.6", "http-body 1.0.0",
"hyper 0.14.28", "http-body-util",
"hyper-tls", "hyper 1.2.0",
"hyper-tls 0.6.0",
"hyper-util",
"ipnet", "ipnet",
"js-sys", "js-sys",
"log", "log",

View File

@@ -38,9 +38,8 @@ serde_repr = "0.1.18"
serde_with = "3.6.1" serde_with = "3.6.1"
serde-aux = "4.4.0" serde-aux = "4.4.0"
futures-util = "0.3.28" futures-util = "0.3.28"
reqwest = { version = "0.11.20", features = [ reqwest = { version = "0.12.0", features = [
"json", "json",
"serde_json",
] } ] }
http = "1.0.0" http = "1.0.0"
governor = "0.6.0" governor = "0.6.0"

View File

@@ -81,12 +81,7 @@ pub async fn add(
&ALPACA_API_BASE, &ALPACA_API_BASE,
) )
.await .await
.map_err(|e| { .map_err(|e| e.status().unwrap_or(StatusCode::INTERNAL_SERVER_ERROR))?
e.status()
.map_or(StatusCode::INTERNAL_SERVER_ERROR, |status| {
StatusCode::from_u16(status.as_u16()).unwrap()
})
})?
.into_iter() .into_iter()
.map(|asset| (asset.symbol.clone(), asset)) .map(|asset| (asset.symbol.clone(), asset))
.collect::<HashMap<_, _>>(); .collect::<HashMap<_, _>>();
@@ -158,12 +153,7 @@ pub async fn add_symbol(
&ALPACA_API_BASE, &ALPACA_API_BASE,
) )
.await .await
.map_err(|e| { .map_err(|e| e.status().unwrap_or(StatusCode::INTERNAL_SERVER_ERROR))?;
e.status()
.map_or(StatusCode::INTERNAL_SERVER_ERROR, |status| {
StatusCode::from_u16(status.as_u16()).unwrap()
})
})?;
if asset.status != types::alpaca::api::incoming::asset::Status::Active if asset.status != types::alpaca::api::incoming::asset::Status::Active
|| !asset.tradable || !asset.tradable

View File

@@ -7,7 +7,7 @@ pub mod news;
pub mod orders; pub mod orders;
pub mod positions; pub mod positions;
use reqwest::StatusCode; use http::StatusCode;
pub fn error_to_backoff(err: reqwest::Error) -> backoff::Error<reqwest::Error> { pub fn error_to_backoff(err: reqwest::Error) -> backoff::Error<reqwest::Error> {
if err.is_status() { if err.is_status() {

View File

@@ -2,6 +2,7 @@ use super::error_to_backoff;
use crate::types::alpaca::api::incoming::position::Position; use crate::types::alpaca::api::incoming::position::Position;
use backoff::{future::retry_notify, ExponentialBackoff}; use backoff::{future::retry_notify, ExponentialBackoff};
use governor::DefaultDirectRateLimiter; use governor::DefaultDirectRateLimiter;
use http::StatusCode;
use log::warn; use log::warn;
use reqwest::Client; use reqwest::Client;
use std::{collections::HashSet, time::Duration}; use std::{collections::HashSet, time::Duration};
@@ -58,7 +59,7 @@ pub async fn get_by_symbol(
.await .await
.map_err(error_to_backoff)?; .map_err(error_to_backoff)?;
if response.status() == reqwest::StatusCode::NOT_FOUND { if response.status() == StatusCode::NOT_FOUND {
return Ok(None); return Ok(None);
} }