Skip to content

rework eventbus scheduled rule execution#23

Open
lizard-boy wants to merge 1 commit intomasterfrom
rework-job-scheduler
Open

rework eventbus scheduled rule execution#23
lizard-boy wants to merge 1 commit intomasterfrom
rework-job-scheduler

Conversation

@lizard-boy
Copy link

Motivation

The key mechanism of the JobScheduler class was a 59.9 second wait event in a while true loop:

We have an event-based scheduler utility that could be used for the JobScheduler, which will also make things easier for our time simulation project.

So this PR is both about cleaning up tech debt and making the JobScheduler more flexible.

Changes

  • Rework JobScheduler using the Scheduler utility
  • ... TODO

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR significantly refactors the EventBridge service in LocalStack, focusing on improving the job scheduling and event dispatching mechanisms.

  • Introduced a new Scheduler utility in utils/scheduler.py for more flexible and efficient task scheduling
  • Implemented CronScheduledTask and Job classes in events/scheduler.py to support both cron and rate expressions
  • Refactored EventsProvider in events/provider.py to use the new JobScheduler for handling scheduled rules
  • Added EventDispatcher and its implementations in events/dispatcher.py for improved event dispatching
  • Updated put_rule, delete_rule, disable_rule, and enable_rule methods to work with the new job scheduling system

5 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings

if expression.startswith("rate"):
return parse_rate_expression(expression)

raise ValueError("Syntax error in expression")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Add more specific error message, e.g., 'Invalid schedule expression. Must start with "cron" or "rate".'

Comment on lines +134 to +135
if task.deadline is None:
task.deadline = max(task.start or 0, time.time())
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider using 'or' instead of 'is None' for more concise code

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

Successfully merging this pull request may close these issues.

2 participants