mirror of
https://git.asonix.dog/asonix/background-jobs.git
synced 2024-11-22 03:51:00 +00:00
core: Add tracing around requesting jobs
This commit is contained in:
parent
21b5a42f67
commit
8af4af8374
1 changed files with 6 additions and 1 deletions
|
@ -305,6 +305,7 @@ pub mod memory_storage {
|
||||||
Ok(self.get_job(&id))
|
Ok(self.get_job(&id))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument(skip(self))]
|
||||||
async fn fetch_job_from_queue(&self, queue: &str) -> Result<JobInfo, Self::Error> {
|
async fn fetch_job_from_queue(&self, queue: &str) -> Result<JobInfo, Self::Error> {
|
||||||
loop {
|
loop {
|
||||||
let now = SystemTime::now();
|
let now = SystemTime::now();
|
||||||
|
@ -313,11 +314,15 @@ pub mod memory_storage {
|
||||||
return Ok(job);
|
return Ok(job);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tracing::debug!("No job ready in queue");
|
||||||
let (duration, listener) = self.listener(queue, now);
|
let (duration, listener) = self.listener(queue, now);
|
||||||
|
tracing::debug!("waiting at most {} seconds", duration.as_secs());
|
||||||
|
|
||||||
|
if duration > Duration::from_secs(0) {
|
||||||
let _ = self.timer.timeout(duration, listener).await;
|
let _ = self.timer.timeout(duration, listener).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async fn queue_job(&self, queue: &str, id: Uuid) -> Result<(), Self::Error> {
|
async fn queue_job(&self, queue: &str, id: Uuid) -> Result<(), Self::Error> {
|
||||||
self.queue_and_notify(queue, id);
|
self.queue_and_notify(queue, id);
|
||||||
|
|
Loading…
Reference in a new issue