فهرست منبع

Improve some syntax

Mauricio Cassola 2 سال پیش
والد
کامیت
f4bf7210bd
3فایلهای تغییر یافته به همراه8 افزوده شده و 6 حذف شده
  1. 1 1
      src/db.rs
  2. 3 3
      src/db/jobs.rs
  3. 4 2
      src/jobs.rs

+ 1 - 1
src/db.rs

@@ -207,7 +207,7 @@ pub async fn run_scheduled_jobs(db: &DbClient) -> anyhow::Result<()> {
 
         match handle_job(&job.name, &job.metadata).await {
             Ok(_) => {
-                tracing::trace!("job succesfully executed (id={})", job.id);
+                tracing::trace!("job successfully executed (id={})", job.id);
                 delete_job(&db, &job.id).await?;
             }
             Err(e) => {

+ 3 - 3
src/db/jobs.rs

@@ -93,7 +93,7 @@ pub async fn get_job_by_name_and_scheduled_at(
         .await
         .context("Select job by name and scheduled at")?;
 
-    serialize_job(&job)
+    deserialize_job(&job)
 }
 
 // Selects all jobs with:
@@ -111,14 +111,14 @@ pub async fn get_jobs_to_execute(db: &DbClient) -> Result<Vec<Job>> {
 
     let mut data = Vec::with_capacity(jobs.len());
     for job in jobs {
-        let serialized_job = serialize_job(&job);
+        let serialized_job = deserialize_job(&job);
         data.push(serialized_job.unwrap());
     }
 
     Ok(data)
 }
 
-fn serialize_job(row: &tokio_postgres::row::Row) -> Result<Job> {
+fn deserialize_job(row: &tokio_postgres::row::Row) -> Result<Job> {
     let id: Uuid = row.try_get(0)?;
     let name: String = row.try_get(1)?;
     let scheduled_at: DateTime<Utc> = row.try_get(2)?;

+ 4 - 2
src/jobs.rs

@@ -35,10 +35,12 @@
 
 use crate::db::jobs::JobSchedule;
 
-// Cadence in seconds with which the jobs will be scheduled
+// How often new cron-based jobs will be placed in the queue.
+// This is the minimum period *between* a single cron task's executions.
 pub const JOB_SCHEDULING_CADENCE_IN_SECS: u64 = 1800;
 
-// Cadence in seconds with which the jobs will be processed
+// How often the database is inspected for jobs which need to execute.
+// This is the granularity at which events will occur.
 pub const JOB_PROCESSING_CADENCE_IN_SECS: u64 = 60;
 
 pub fn jobs() -> Vec<JobSchedule> {