Skip to content

Commit

Permalink
feat(sentry-tower) Make SentryLayer and SentryService Sync if reque…
Browse files Browse the repository at this point in the history
…st isn't
  • Loading branch information
syphar committed Jan 7, 2025
1 parent fd92a32 commit 7e8d7dd
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions sentry-tower/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ where
H: Into<Arc<Hub>>,
{
provider: P,
_hub: PhantomData<(H, Request)>,
_hub: PhantomData<(H, fn() -> Request)>,
}

impl<S, P, H, Request> Layer<S> for SentryLayer<P, H, Request>
Expand Down Expand Up @@ -250,7 +250,7 @@ where
{
service: S,
provider: P,
_hub: PhantomData<(H, Request)>,
_hub: PhantomData<(H, fn() -> Request)>,
}

impl<S, Request, P, H> Service<Request> for SentryService<S, P, H, Request>
Expand Down Expand Up @@ -326,3 +326,21 @@ impl<S, Request> NewSentryService<S, Request> {
}
}
}

#[cfg(test)]
mod tests {
use super::*;
use std::rc::Rc;

fn assert_sync<T: Sync>() {}

#[test]
fn test_layer_is_sync_when_request_isnt() {
assert_sync::<NewSentryLayer<Rc<()>>>(); // Rc<()> is not Sync
}

#[test]
fn test_service_is_sync_when_request_isnt() {
assert_sync::<NewSentryService<(), Rc<()>>>(); // Rc<()> is not Sync
}
}

0 comments on commit 7e8d7dd

Please sign in to comment.