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

feature: cron implementation #1194

Merged
merged 5 commits into from
Apr 8, 2024
Merged

feature: cron implementation #1194

merged 5 commits into from
Apr 8, 2024

Conversation

matt2e
Copy link
Collaborator

@matt2e matt2e commented Apr 8, 2024

Built a cron implementation which will be used as part of our cron jobs feature (See: #1155)
Splitting this off into this smaller PR to make things easier.

# Conflicts:
#	buildengine/testdata/projects/another/go.sum
#	go-runtime/compile/testdata/one/go.sum
#	go-runtime/compile/testdata/two/go.sum

# Conflicts:
#	backend/controller/cronjobs/cronjobs.go
#	backend/schema/metadatacronjob.go
#	backend/schema/validate.go
@matt2e matt2e mentioned this pull request Apr 8, 2024
14 tasks
Copy link
Collaborator

@alecthomas alecthomas left a comment

Choose a reason for hiding this comment

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

Nice!

components[6] = newComponentWithFullRange()
return components, nil
case 6:
// Might be two different formats unfortunately.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are these semantics the same as other implementations?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I haven't found a neat single place that defines it well, but this part of wikipedia helps show its a bit of a wild west https://en.wikipedia.org/wiki/Cron#Cron_expression
Note the year being optional (and not in standard versions) and that "In some uses of the cron format there is also a seconds field at the beginning of the pattern. In that case, the cron expression is a string comprising 6 or 7 fields."

I looked into how gronx handled this and they look for a 4 digit number to determine if it is a year, which is what I've done here as well.
https://github.com/adhocore/gronx/blob/d84c38971549dda6eb2803d83756e340fd40c297/gronx.go#L105

internal/cron/cron.go Outdated Show resolved Hide resolved
internal/cron/cron_test.go Outdated Show resolved Hide resolved
internal/cron/cron_test.go Outdated Show resolved Hide resolved
internal/cron/cron_test.go Outdated Show resolved Hide resolved
internal/cron/cron_test.go Outdated Show resolved Hide resolved
@matt2e matt2e merged commit 3b715e3 into main Apr 8, 2024
11 checks passed
@matt2e matt2e deleted the matt2e/cron-package branch April 8, 2024 01:26
matt2e added a commit that referenced this pull request Apr 15, 2024
- [x] Schema changes
- [x] Module validation
- [x] Support multiple controllers using hash ring
- [x] DB indexes
- [x] Tests
    - [x] CronJobs Service
    - [x] cron lib
    - [x] schema changes

Separating into different PRs:
- [x] cron implementation: #1194
- [x] deepcopy: #1195
- [x] metadata changes #1216
- [x] db level changes: #1229 
- [ ] Afterwards: ftl-examples
- [ ] Afterwards: add event for it to show in web console

#1141
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