Replies: 3 comments 9 replies
-
All storage have a `fetch_by_id` method. It should give you the updated
version of a job.
…On Mon, 1 Jul 2024 at 10:12, hldup ***@***.***> wrote:
Hey, I have an axum server that deploys jobs to different kinds of
microservices. All it basically does is send jobs to the microservices and
wait do other stuff in the meanwhile. Then once it has finished I want it
to check up on the job I have dispatched to the microservice.
Is there a function or any way to query the RedisStorage to check if a job
has finished?
—
Reply to this email directly, view it on GitHub
<#340>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AWXVRGQO2BP4KCCZJDELLPDZKD6PFAVCNFSM6AAAAABKE6P6DGVHI2DSMVQWIX3LMV43ERDJONRXK43TNFXW4OZWHA4DINJWG4>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
1 reply
-
I have made a basic wrapper function that executes a trait function that is implemented to a struct that implements apalis::prelude::Job. main.rs Monitor::<TokioExecutor>::new()
.register_with_count(4, {
WorkerBuilder::new("edit-runner")
.layer(TraceLayer::new())
.with_storage(storage.clone())
.data(state.clone())
.build_fn(jobhandler::run_job::<EditorJob, State>)
})
.run()
.await
.unwrap(); jobhandler::run_job() pub async fn run_job<T, S>(mut job: T, state: Data<S>)
where
T: Serialize + DeserializeOwned + Send + 'static + Unpin + Job + Sync + JobRunner<T, S>,
S: StateHandler,
{
match job.run(state).await {
Ok(_) => {
log::debug!("Job has finished ok");
job.set_status(JobStatus::Ok)
}
Err(error) => {
log::error!("job has failed");
job.set_status(JobStatus::Error("failed".into()))
}
};
} job.rs impl JobRunner<EditorJob, crate::State> for EditorJob {
async fn run(&mut self, state: Data<crate::State>) -> Result<(), jobhandler::JobError> {
thread::sleep(Duration::from_secs(35));
Ok(())
}
fn set_status(&mut self, status: jobhandler::JobStatus) {
self.set_status(status);
}
fn get_status(&self) -> jobhandler::JobStatus {
self.status().to_owned()
}
} |
Beta Was this translation helpful? Give feedback.
1 reply
-
Does fetch_with_id + update work for you? |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey, I have an axum server that deploys jobs to different kinds of microservices. All it basically does is send jobs to the microservices and wait do other stuff in the meanwhile. Then once it has finished I want it to check up on the job I have dispatched to the microservice.
Is there a function or any way to query the RedisStorage to check if a job has finished?
Beta Was this translation helpful? Give feedback.
All reactions