feat: transform sync func to async func
This commit is contained in:
parent
2fd1201615
commit
d4b7364719
@ -71,11 +71,11 @@ impl ScheduleJob {
|
||||
|
||||
#[instrument(skip(self))]
|
||||
pub async fn add_cron_job(&mut self, server_id: u64, channel_id: u64, cron_expression: String) {
|
||||
let job_fn = move |uuid, _l| {
|
||||
// Do something
|
||||
info!("Cron job executed with id: {:?}", uuid);
|
||||
};
|
||||
let job = match Job::new(cron_expression.as_str(), job_fn) {
|
||||
let job = match Job::new_async(cron_expression.as_str(), |uuid, _l| {
|
||||
Box::pin(async move {
|
||||
info!("Cron job fired: {:?}", uuid);
|
||||
})
|
||||
}) {
|
||||
Ok(job) => job,
|
||||
Err(e) => {
|
||||
error!("Error creating cron job: {:?}", e);
|
||||
|
Loading…
Reference in New Issue
Block a user