Skip to content

Commit ec165f9

Browse files
committed
feat(sentry-tower) Make SentryLayer and SentryService Sync if request isn't
1 parent fd92a32 commit ec165f9

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

sentry-tower/src/lib.rs

Lines changed: 21 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,22 @@ 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+
#[allow(dead_code)]
336+
fn assert_sync<T: Sync>() {}
337+
338+
#[allow(dead_code)]
339+
fn test_layer_is_sync_when_request_isnt() {
340+
assert_sync::<NewSentryLayer<Rc<()>>>(); // Rc<()> is not Sync
341+
}
342+
343+
#[allow(dead_code)]
344+
fn test_service_is_sync_when_request_isnt() {
345+
assert_sync::<NewSentryService<(), Rc<()>>>(); // Rc<()> is not Sync
346+
}
347+
}

0 commit comments

Comments
 (0)