Skip to content

Commit c97ba6c

Browse files
authored
feat(sentry-tower) Make SentryLayer and SentryService Sync if request isn't (#721)
1 parent 5cdf7fc commit c97ba6c

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

sentry-tower/src/lib.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ where
196196
H: Into<Arc<Hub>>,
197197
{
198198
provider: P,
199-
_hub: PhantomData<(H, Request)>,
199+
_hub: PhantomData<(H, fn() -> Request)>,
200200
}
201201

202202
impl<S, P, H, Request> Layer<S> for SentryLayer<P, H, Request>
@@ -250,7 +250,7 @@ where
250250
{
251251
service: S,
252252
provider: P,
253-
_hub: PhantomData<(H, Request)>,
253+
_hub: PhantomData<(H, fn() -> Request)>,
254254
}
255255

256256
impl<S, Request, P, H> Service<Request> for SentryService<S, P, H, Request>
@@ -326,3 +326,21 @@ impl<S, Request> NewSentryService<S, Request> {
326326
}
327327
}
328328
}
329+
330+
#[cfg(test)]
331+
mod tests {
332+
use super::*;
333+
use std::rc::Rc;
334+
335+
fn assert_sync<T: Sync>() {}
336+
337+
#[test]
338+
fn test_layer_is_sync_when_request_isnt() {
339+
assert_sync::<NewSentryLayer<Rc<()>>>(); // Rc<()> is not Sync
340+
}
341+
342+
#[test]
343+
fn test_service_is_sync_when_request_isnt() {
344+
assert_sync::<NewSentryService<(), Rc<()>>>(); // Rc<()> is not Sync
345+
}
346+
}

0 commit comments

Comments
 (0)