mirror of
https://git.asonix.dog/asonix/pict-rs.git
synced 2024-11-24 18:41:06 +00:00
Return JobId from push
This commit is contained in:
parent
5d4486fdf4
commit
e4e93cddf9
2 changed files with 5 additions and 5 deletions
|
@ -303,7 +303,7 @@ impl JobId {
|
|||
|
||||
#[async_trait::async_trait(?Send)]
|
||||
pub(crate) trait QueueRepo: BaseRepo {
|
||||
async fn push(&self, queue: &'static str, job: Self::Bytes) -> Result<(), RepoError>;
|
||||
async fn push(&self, queue: &'static str, job: Self::Bytes) -> Result<JobId, RepoError>;
|
||||
|
||||
async fn pop(&self, queue: &'static str) -> Result<(JobId, Self::Bytes), RepoError>;
|
||||
|
||||
|
@ -317,7 +317,7 @@ impl<T> QueueRepo for actix_web::web::Data<T>
|
|||
where
|
||||
T: QueueRepo,
|
||||
{
|
||||
async fn push(&self, queue: &'static str, job: Self::Bytes) -> Result<(), RepoError> {
|
||||
async fn push(&self, queue: &'static str, job: Self::Bytes) -> Result<JobId, RepoError> {
|
||||
T::push(self, queue, job).await
|
||||
}
|
||||
|
||||
|
|
|
@ -663,7 +663,7 @@ fn job_key(queue: &'static str, job_id: JobId) -> Arc<[u8]> {
|
|||
#[async_trait::async_trait(?Send)]
|
||||
impl QueueRepo for SledRepo {
|
||||
#[tracing::instrument(skip(self, job), fields(job = %String::from_utf8_lossy(&job)))]
|
||||
async fn push(&self, queue_name: &'static str, job: Self::Bytes) -> Result<(), RepoError> {
|
||||
async fn push(&self, queue_name: &'static str, job: Self::Bytes) -> Result<JobId, RepoError> {
|
||||
let metrics_guard = PushMetricsGuard::guard(queue_name);
|
||||
|
||||
let id = JobId::gen();
|
||||
|
@ -692,7 +692,7 @@ impl QueueRepo for SledRepo {
|
|||
if let Some(notifier) = self.queue_notifier.read().unwrap().get(&queue_name) {
|
||||
notifier.notify_one();
|
||||
metrics_guard.disarm();
|
||||
return Ok(());
|
||||
return Ok(id);
|
||||
}
|
||||
|
||||
self.queue_notifier
|
||||
|
@ -704,7 +704,7 @@ impl QueueRepo for SledRepo {
|
|||
|
||||
metrics_guard.disarm();
|
||||
|
||||
Ok(())
|
||||
Ok(id)
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self))]
|
||||
|
|
Loading…
Reference in a new issue