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))]
|
#[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);
|
||||||
|
Loading…
Reference in New Issue
Block a user