Open Dkwcs opened 1 year ago
Maybe much more simple way exists?
I would also be interested in a recommended approach for resuming jobs with tokio-cron-scheduler
. Currently, I'm following a similar approach to what @Dkwcs is doing: fetching the job list and analyzing the extra
to determine the specific job type: https://github.com/secutils-dev/secutils/blob/2f6c10bc5c47e0ef217fbd7874dd41ceda41ba8e/src/scheduler.rs#L79
Also metadata_storage trait doesn't have get_all method, only get_by_id( It would be a lot easier to support jobs resume functionality if here no other ways exist.
The key point here is actually how to correspond to JobCode
. I took a brief look at the source code, and the crucial implementation is the implementation of this trait JobCode
.
We need to customize our own implementation of JobCode
, but there is a technical challenge here. The ID of this Job needs to be generated by ourselves so that we have a chance to match it after program restarts. However, its internal actual implementation is creating a new UUID every time: let job_id = Uuid::new_v4();
.
Looking forward to the author providing a good solution directly.
@Dkwcs - the get_all method will definitely help in this regard, also to specify the GUID in creating a Job. Should be simple?
For now I see only one way to resume jobs execution after reloading service. I have added custom wrapper over metadata_storage to get all jobs ids then data and use this jobs data to recreate jobs and run them again. Maybe much more simple way exists?