Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions adapter/cron/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ fn extract_flow_setting_field(flow: &ValidationFlow, name: &str) -> Option<Strin

impl IdentifiableFlow for Time {
fn identify(&self, flow: &tucana::shared::ValidationFlow) -> bool {
log::debug!("Trying to identify flow with flow id: {}", flow.flow_id);
let Some(minute) = extract_flow_setting_field(flow, "cronMinute") else {
return false;
};
Expand All @@ -73,6 +74,16 @@ impl IdentifiableFlow for Time {
return false;
};

log::debug!(
"flow with id: {} has the following cron configuration {} {} {} {} {}",
flow.flow_id,
minute,
hour,
dom,
month,
dow
);

Comment thread
raphael-goetz marked this conversation as resolved.
let expression = format!("* {} {} {} {} {}", minute, hour, dom, month, dow);
let schedule = match Schedule::from_str(expression.as_str()) {
Ok(s) => s,
Expand All @@ -93,11 +104,19 @@ impl IdentifiableFlow for Time {
}
};

self.now.year() == next.year()
let is_match = self.now.year() == next.year()
&& self.now.month() == next.month()
&& self.now.day() == next.day()
&& self.now.hour() == next.hour()
&& self.now.minute() == next.minute()
&& self.now.minute() == next.minute();

if is_match {
log::debug!("Flow with id: {} was a match", flow.flow_id);
} else {
log::debug!("Flow with id: {} was no match", flow.flow_id);
}

is_match
}
}

Expand All @@ -111,7 +130,7 @@ impl Server<CronConfig> for Cron {
log::info!("Starting Cron adapter");
let expression = "0 * * * * *";
let schedule = Schedule::from_str(expression)?;
let pattern = "CRON.<";
let pattern = "CRON.*";

loop {
let now = Utc::now();
Expand Down