Go: Configuring workflow for run every second
Hi everyone... I want to create a simple workflow and i need execute that every second. but when i use Cron configuration, for all intervals under a second, workflow is not executed. this is my workflow register:
worker.WorkflowJob {
return worker.WorkflowJob{
Name: "schedule-workflow",
Description: "Simple multi-step workflow.",
On: worker.Cron("* * * * * *"),
ScheduleTimeout: "120s",
Concurrency: worker.Concurrency(getConcurrencyKey).MaxRuns(100).LimitStrategy(types.GroupRoundRobin),
Steps: []*worker.WorkflowStep{
worker.Fn(steps.One).SetName("step-one"),
worker.Fn(steps.Two).SetName("step-two").AddParents("step-one"),
},
}
thank you for your time
Hey @Apkahym, our cron syntax only supports minute granularity, it doesn't support seconds. One way around this is to create a parent workflow which runs every minute which spawns new workflows every second for 60 seconds. I know this isn't the most ideal solution, but it's currently the best option.
Hi @abelanger5, thanks for taking some time to reply to me. I found an alternative to the classic cron syntax (* * * * * *) in the cron module documentation and it works relatively. This alternative uses the @every <unit of time> reservation word.
When I say "it works relatively" I mean that the workflow runs every second, but the rest of the ecosystem doesn't respond in time and runs slowly.
Right now I'm looking for an alternative to check the conditional state I need to run a workflow, but this solution is probably external to hatchet.