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

View File

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

View File

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

View File

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

View File

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