Skip to content

Commit 7da396b

Browse files
Merge pull request #206 from code0-tech/#205-cron-fix
correct flow identification syntax
2 parents ac2c1bd + c109033 commit 7da396b

1 file changed

Lines changed: 22 additions & 3 deletions

File tree

adapter/cron/src/main.rs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ fn extract_flow_setting_field(flow: &ValidationFlow, name: &str) -> Option<Strin
5757

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

77+
log::debug!(
78+
"flow with id: {} has the following cron configuration {} {} {} {} {}",
79+
flow.flow_id,
80+
minute,
81+
hour,
82+
dom,
83+
month,
84+
dow
85+
);
86+
7687
let expression = format!("* {} {} {} {} {}", minute, hour, dom, month, dow);
7788
let schedule = match Schedule::from_str(expression.as_str()) {
7889
Ok(s) => s,
@@ -93,11 +104,19 @@ impl IdentifiableFlow for Time {
93104
}
94105
};
95106

96-
self.now.year() == next.year()
107+
let is_match = self.now.year() == next.year()
97108
&& self.now.month() == next.month()
98109
&& self.now.day() == next.day()
99110
&& self.now.hour() == next.hour()
100-
&& self.now.minute() == next.minute()
111+
&& self.now.minute() == next.minute();
112+
113+
if is_match {
114+
log::debug!("Flow with id: {} was a match", flow.flow_id);
115+
} else {
116+
log::debug!("Flow with id: {} was no match", flow.flow_id);
117+
}
118+
119+
is_match
101120
}
102121
}
103122

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

116135
loop {
117136
let now = Utc::now();

0 commit comments

Comments
 (0)