feat: transform sync func to async func

This commit is contained in:
Max batleforc 2024-06-24 19:12:32 +02:00
parent 2fd1201615
commit d4b7364719
No known key found for this signature in database
GPG Key ID: 25D243AB4B6AC9E7

View File

@ -71,11 +71,11 @@ impl ScheduleJob {
#[instrument(skip(self))] #[instrument(skip(self))]
pub async fn add_cron_job(&mut self, server_id: u64, channel_id: u64, cron_expression: String) { pub async fn add_cron_job(&mut self, server_id: u64, channel_id: u64, cron_expression: String) {
let job_fn = move |uuid, _l| { let job = match Job::new_async(cron_expression.as_str(), |uuid, _l| {
// Do something Box::pin(async move {
info!("Cron job executed with id: {:?}", uuid); info!("Cron job fired: {:?}", uuid);
}; })
let job = match Job::new(cron_expression.as_str(), job_fn) { }) {
Ok(job) => job, Ok(job) => job,
Err(e) => { Err(e) => {
error!("Error creating cron job: {:?}", e); error!("Error creating cron job: {:?}", e);