Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Go: Configuring workflow for run every second #822

Open
Apkahym opened this issue Aug 26, 2024 · 2 comments
Open

Go: Configuring workflow for run every second #822

Apkahym opened this issue Aug 26, 2024 · 2 comments

Comments

@Apkahym
Copy link

Apkahym commented Aug 26, 2024

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

@abelanger5
Copy link
Contributor

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.

@Apkahym
Copy link
Author

Apkahym commented Aug 27, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@Apkahym @abelanger5 and others