modified task entrypoint
This commit is contained in:
parent
2d00604c6f
commit
66ba89c0b1
@ -1,9 +1,9 @@
|
||||
use chrono::Utc;
|
||||
use sqlx::{postgres::PgPoolOptions, Pool, Postgres};
|
||||
use tasks::import_posts;
|
||||
use std::env;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use tasks::import_posts;
|
||||
|
||||
//mod config;
|
||||
mod tasks;
|
||||
@ -19,15 +19,15 @@ pub struct TaskManager<'a> {
|
||||
|
||||
#[derive(Debug, sqlx::FromRow)]
|
||||
pub struct TaskLog {
|
||||
log_id: u8,
|
||||
task_id: u8,
|
||||
log_id: i32,
|
||||
task_id: i32,
|
||||
created_at: chrono::DateTime<Utc>,
|
||||
task_status: TaskStatus,
|
||||
task_status: String,
|
||||
finished_at: Option<chrono::DateTime<Utc>>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
enum TaskStatus {
|
||||
pub enum TaskStatus {
|
||||
Pending(String),
|
||||
Completed(String),
|
||||
Failed(String),
|
||||
@ -88,11 +88,9 @@ impl<'a> TaskManager<'a> {
|
||||
results.iter().for_each(|r| {
|
||||
println!("Registering job: {:?}", r.task_name);
|
||||
|
||||
let job: _ = job_scheduler::Job::new(r.schedule.parse().unwrap(), || {
|
||||
match r.task_id {
|
||||
let job: _ = job_scheduler::Job::new(r.schedule.parse().unwrap(), || match r.task_id {
|
||||
1 => import_posts::register(&Arc::new(&self.pool)),
|
||||
_ => panic!(),
|
||||
}
|
||||
});
|
||||
|
||||
scheduler.add(job);
|
||||
|
Loading…
Reference in New Issue
Block a user