Add Created status to JobStatus enum and store_job_in_redis_with_status method

This commit is contained in:
Timur Gordon
2025-11-03 13:29:28 +01:00
parent df8fc69678
commit 0588b2736b
3 changed files with 14 additions and 17 deletions

View File

@@ -204,8 +204,8 @@ impl Client {
Ok(())
}
/// Store this job in Redis
pub async fn store_job_in_redis(&self, job: &Job) -> Result<(), JobError> {
/// Store this job in Redis with the specified status
pub async fn store_job_in_redis_with_status(&self, job: &Job, status: JobStatus) -> Result<(), JobError> {
let mut conn = self.redis_client
.get_multiplexed_async_connection()
.await
@@ -220,7 +220,7 @@ impl Client {
// Store job data in Redis hash
let _: () = conn.hset_multiple(&job_key, &[
("data", job_data),
("status", JobStatus::Dispatched.as_str().to_string()),
("status", status.as_str().to_string()),
("created_at", job.created_at.to_rfc3339()),
("updated_at", job.updated_at.to_rfc3339()),
]).await
@@ -232,6 +232,11 @@ impl Client {
Ok(())
}
/// Store this job in Redis (defaults to Dispatched status for backwards compatibility)
pub async fn store_job_in_redis(&self, job: &Job) -> Result<(), JobError> {
self.store_job_in_redis_with_status(job, JobStatus::Dispatched).await
}
/// Load a job from Redis by ID
pub async fn load_job_from_redis(