mirror of
https://git.asonix.dog/asonix/background-jobs.git
synced 2024-11-21 19:40:59 +00:00
Port warn on drop from 0.9.x
This commit is contained in:
parent
c0ce6f303e
commit
461c9e5ed2
1 changed files with 16 additions and 1 deletions
|
@ -56,6 +56,19 @@ impl Worker for LocalWorkerHandle {
|
|||
}
|
||||
}
|
||||
|
||||
struct LogOnDrop<F>(F)
|
||||
where
|
||||
F: Fn() -> Span;
|
||||
|
||||
impl<F> Drop for LogOnDrop<F>
|
||||
where
|
||||
F: Fn() -> Span,
|
||||
{
|
||||
fn drop(&mut self) {
|
||||
(self.0)().in_scope(|| info!("Worker closing"));
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) async fn local_worker<State>(
|
||||
queue: String,
|
||||
processors: CachedProcessorMap<State>,
|
||||
|
@ -68,6 +81,8 @@ pub(crate) async fn local_worker<State>(
|
|||
|
||||
let handle = LocalWorkerHandle { tx, id, queue };
|
||||
|
||||
let log_on_drop = LogOnDrop(|| handle.span("closing"));
|
||||
|
||||
loop {
|
||||
let span = handle.span("request");
|
||||
if let Err(e) = server
|
||||
|
@ -105,5 +120,5 @@ pub(crate) async fn local_worker<State>(
|
|||
break;
|
||||
}
|
||||
|
||||
handle.span("closing").in_scope(|| info!("Worker closing"));
|
||||
drop(log_on_drop);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue