Skip to content

Commit

Permalink
fixup! feat: add embedded-svc based http transport
Browse files Browse the repository at this point in the history
Disabling the esp-idf-svc transport if not compiling for espidf is not
too elegant. I would have preferred to add a sample esp32 project and
make it work that way, but that would have created a lot of esp32
related files in the root of the workspace and also would have required
running the checks with a *-esp-espidf rust target.
  • Loading branch information
madmo committed Apr 16, 2024
1 parent 40f0c3a commit 38286a7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions sentry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ rustls = { version = "0.21.2", optional = true, features = [
] }
webpki-roots = { version = "0.25.1", optional = true }
embedded-svc = { version = "0.27.1", optional = true }
[target.'cfg(target_os = "espidf")'.dependencies]
esp-idf-svc = { version = "0.48.1", optional = true }

[dev-dependencies]
Expand Down
17 changes: 9 additions & 8 deletions sentry/src/transports/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ mod reqwest;
#[cfg(feature = "reqwest")]
pub use self::reqwest::ReqwestHttpTransport;

#[cfg(feature = "embedded-svc-http")]
#[cfg(all(target_os = "espidf", feature = "embedded-svc-http"))]
mod embedded_svc_http;
#[cfg(feature = "embedded-svc-http")]
#[cfg(all(target_os = "espidf", feature = "embedded-svc-http"))]
pub use self::embedded_svc_http::EmbeddedSVCHttpTransport;

#[cfg(feature = "curl")]
Expand All @@ -43,7 +43,7 @@ type DefaultTransport = ReqwestHttpTransport;

#[cfg(all(
feature = "curl",
not(feature = "embedded-svc-http"),
not(all(target_os = "espidf", feature = "embedded-svc-http")),
not(feature = "reqwest"),
not(feature = "surf"),
not(feature = "ureq")
Expand All @@ -52,7 +52,7 @@ type DefaultTransport = CurlHttpTransport;

#[cfg(all(
feature = "surf",
not(feature = "embedded-svc-http"),
not(all(target_os = "espidf", feature = "embedded-svc-http")),
not(feature = "reqwest"),
not(feature = "curl"),
not(feature = "ureq")
Expand All @@ -61,14 +61,15 @@ type DefaultTransport = SurfHttpTransport;

#[cfg(all(
feature = "ureq",
not(feature = "embedded-svc-http"),
not(all(target_os = "espidf", feature = "embedded-svc-http")),
not(feature = "reqwest"),
not(feature = "curl"),
not(feature = "surf")
))]
type DefaultTransport = UreqHttpTransport;

#[cfg(all(
target_os = "espidf",
feature = "embedded-svc-http",
not(feature = "reqwest"),
not(feature = "curl"),
Expand All @@ -79,7 +80,7 @@ type DefaultTransport = EmbeddedSVCHttpTransport;

/// The default http transport.
#[cfg(any(
feature = "embedded-svc-http",
all(target_os = "espidf", feature = "embedded-svc-http"),
feature = "reqwest",
feature = "curl",
feature = "surf",
Expand All @@ -98,7 +99,7 @@ pub struct DefaultTransportFactory;
impl TransportFactory for DefaultTransportFactory {
fn create_transport(&self, options: &ClientOptions) -> Arc<dyn Transport> {
#[cfg(any(
feature = "embedded-svc-http",
all(target_os = "espidf", feature = "embedded-svc-http"),
feature = "reqwest",
feature = "curl",
feature = "surf",
Expand All @@ -108,7 +109,7 @@ impl TransportFactory for DefaultTransportFactory {
Arc::new(HttpTransport::new(options))
}
#[cfg(not(any(
feature = "embedded-svc-http",
all(target_os = "espidf", feature = "embedded-svc-http"),
feature = "reqwest",
feature = "curl",
feature = "surf",
Expand Down

0 comments on commit 38286a7

Please sign in to comment.