Skip to content

Commit f60ad02

Browse files
committed
fix: correct flow identification syntax
1 parent ac2c1bd commit f60ad02

1 file changed

Lines changed: 25 additions & 3 deletions

File tree

adapter/cron/src/main.rs

Lines changed: 25 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,22 @@ 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+
match is_match {
114+
true => {
115+
log::debug!("Flow with id: {} was a match", flow.flow_id);
116+
is_match
117+
}
118+
false => {
119+
log::debug!("Flow with id: {} was no match", flow.flow_id);
120+
is_match
121+
}
122+
}
101123
}
102124
}
103125

@@ -111,7 +133,7 @@ impl Server<CronConfig> for Cron {
111133
log::info!("Starting Cron adapter");
112134
let expression = "0 * * * * *";
113135
let schedule = Schedule::from_str(expression)?;
114-
let pattern = "CRON.<";
136+
let pattern = "CRON.*";
115137

116138
loop {
117139
let now = Utc::now();

0 commit comments

Comments
 (0)