Skip to content

Commit

Permalink
make NoopClient feature dependant (Azure#1380)
Browse files Browse the repository at this point in the history
Instead of always compiling in NoopClient, make it something that's only available if the reqwest clients were not enabled.
  • Loading branch information
demoray authored Sep 15, 2023
1 parent ed7b92d commit 1dca228
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions sdk/core/src/http_client/mod.rs
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
#[cfg(not(any(feature = "enable_reqwest", feature = "enable_reqwest_rustls")))]
mod noop;
#[cfg(any(feature = "enable_reqwest", feature = "enable_reqwest_rustls"))]
mod reqwest;

#[cfg(not(any(feature = "enable_reqwest", feature = "enable_reqwest_rustls")))]
use self::noop::NoopClient;
#[cfg(any(feature = "enable_reqwest", feature = "enable_reqwest_rustls"))]
pub use self::reqwest::*;
pub use noop::*;

use self::reqwest::*;
use crate::error::ErrorKind;
use async_trait::async_trait;
use bytes::Bytes;
use serde::Serialize;
use std::sync::Arc;

/// Construct a new `HttpClient`
pub fn new_http_client() -> Arc<dyn HttpClient> {
#[allow(unused)]
let http_client: Arc<dyn HttpClient> = Arc::new(NoopClient);
#[cfg(any(feature = "enable_reqwest", feature = "enable_reqwest_rustls"))]
let http_client = new_reqwest_client();
http_client
{
new_reqwest_client()
}
#[cfg(not(any(feature = "enable_reqwest", feature = "enable_reqwest_rustls")))]
{
Arc::new(NoopClient)
}
}

use crate::error::ErrorKind;
use async_trait::async_trait;
use bytes::Bytes;
use serde::Serialize;

/// An HTTP client which can send requests.
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
Expand Down

0 comments on commit 1dca228

Please sign in to comment.