feat(cron): migrate from robfig/cron/v3 to hyp3rd/cron/v4#87
Merged
Conversation
Replace the `github.com/robfig/cron/v3` dependency with the internal `github.com/hyp3rd/cron/v4` fork across all cron-related files. Key changes: - Switch all cron entry scheduling to `scheduleCronEntry`, which wraps the new `ScheduleNamed` API to associate a name with each entry, enabling direct name resolution in `AdminSchedules` without requiring a reverse-lookup map fallback. - Update `cronJob` signature from `func()` to `func(context.Context) error` to align with the new `FuncJob` interface, and propagate the job's context through to `runDurableCron` and `runInMemoryCron`. - Update `skipCronTick` to also check the job-provided context in addition to the TaskManager's own context. - Replace `cron.NewParser` with `cron.NewSpecParser` throughout. - Pass context to `cron.Start` and handle the error returned by `cron.Stop`, ignoring expected cancellation errors. - Update `go.mod` and `go.sum` accordingly.
There was a problem hiding this comment.
Pull request overview
Migrates the worker scheduler from github.com/robfig/cron/v3 to the internal fork github.com/hyp3rd/cron/v4, updating scheduling and lifecycle handling to match the new API and improving schedule name resolution in admin views.
Changes:
- Replace
SchedulewithScheduleNamedvia ascheduleCronEntryhelper and useentry.NameinAdminSchedules(with map fallback). - Update cron job execution to accept a
context.Context(and propagate it into task factories / registrations); extendskipCronTickto consider the job context. - Switch parsers to
NewSpecParser, pass context intocron.Start, and handle errors fromcron.Stop; updatego.mod/go.sumand imports accordingly.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| worker.go | Swap cron dependency import to github.com/hyp3rd/cron/v4. |
| cron.go | Core migration: ScheduleNamed wrapper, context-aware cron jobs, parser + Start/Stop API updates. |
| admin_taskmanager.go | Prefer entry.Name for schedule listing; use scheduleCronEntry when creating schedules. |
| go.mod | Replace robfig/cron/v3 with hyp3rd/cron/v4. |
| go.sum | Add checksums for hyp3rd/cron/v4 and remove robfig/cron/v3. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool. What Enabling Code Scanning Means:
For more information about GitHub Code Scanning, check out the documentation. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace the
github.com/robfig/cron/v3dependency with the internalgithub.com/hyp3rd/cron/v4fork across all cron-related files.Key changes:
scheduleCronEntry, which wraps the newScheduleNamedAPI to associate a name with each entry, enabling direct name resolution inAdminScheduleswithout requiring a reverse-lookup map fallback.cronJobsignature fromfunc()tofunc(context.Context) errorto align with the newFuncJobinterface, and propagate the job's context through torunDurableCronandrunInMemoryCron.skipCronTickto also check the job-provided context in addition to the TaskManager's own context.cron.NewParserwithcron.NewSpecParserthroughout.cron.Startand handle the error returned bycron.Stop, ignoring expected cancellation errors.go.modandgo.sumaccordingly.