Skip to content

Commit 6aafcac

Browse files
committed
Trigger ticks every seconds per default when a tick handler is provided
Signed-off-by: Didier Wenzek <didier.wenzek@free.fr>
1 parent c2e12a0 commit 6aafcac

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

crates/extensions/tedge_gen_mapper/src/config.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl PipelineConfig {
5252
let stage = StageConfig {
5353
filter: FilterSpec::JavaScript(filter),
5454
config: None,
55-
tick_every_seconds: 1,
55+
tick_every_seconds: 0,
5656
meta_topics: vec![],
5757
};
5858
Self {
@@ -73,6 +73,7 @@ impl PipelineConfig {
7373
let mut stage = stage.compile(config_dir, i, &source).await?;
7474
js_runtime.load_filter(&mut stage.filter).await?;
7575
stage.check(&source);
76+
stage.fix();
7677
stages.push(stage);
7778
}
7879
Ok(Pipeline {

crates/extensions/tedge_gen_mapper/src/pipeline.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,14 @@ impl Stage {
133133
warn!(target: "MAPPING", "Filter with no 'tick' function: {}; but configured with 'tick_every_seconds' in {pipeline}", filter.path.display());
134134
}
135135
}
136+
137+
pub(crate) fn fix(&mut self) {
138+
let filter = &mut self.filter;
139+
if !filter.no_js_tick && filter.tick_every_seconds == 0 {
140+
// 0 as a default is not appropriate for a filter with a tick handler
141+
filter.tick_every_seconds = 1;
142+
}
143+
}
136144
}
137145

138146
impl DateTime {

0 commit comments

Comments
 (0)