2
0
Fork 0
mirror of https://git.asonix.dog/asonix/pict-rs synced 2024-12-22 11:21:24 +00:00

Return JobId from push

This commit is contained in:
asonix 2023-08-13 19:52:27 -05:00
parent 5d4486fdf4
commit e4e93cddf9
2 changed files with 5 additions and 5 deletions

View file

@ -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
}

View file

@ -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))]