-
-
Notifications
You must be signed in to change notification settings - Fork 304
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
[BUG] - Current Job Not Correct In DoWithJobDetails with SingletonMode #520
Comments
Hi @forstef Could you provide more details about what you're seeing vs. expecting? It appears to be working as I'd expect. One slightly confusing note is that within the job run the
On the initial two runs PreviousRun won't be populated, and on the first run LastRun won't be populated. package main
import (
"log"
"time"
"github.com/go-co-op/gocron"
)
func main() {
s := gocron.NewScheduler(time.UTC)
_, err := s.Every(1).Seconds().DoWithJobDetails(func(job gocron.Job) {
log.Printf("\nprevious:\t%s\nlast:\t\t%s\nnow:\t\t%s\nnext:\t\t%s\n\n\n", job.PreviousRun(), job.LastRun(), time.Now().UTC(), job.NextRun())
})
if err != nil {
panic(err)
}
s.StartBlocking()
} Output:
|
When you added s.SingletonModeAll() behind s := gocron.NewScheduler(time.UTC), you would get the issue. |
Describe the bug
Called function: s.Every(xxx).Seconds().DoWithJobDetails(f)
But in
func f(job gocron.Job){
// you always get the same return from job.NextRun() and LastRun(), it is the first value and did not change in every call
}
Version
1.29.0
Expected behavior
job.NextRun(),LastRun() should get the time for the next run in task function, according to scheduler.
Probably other current job related functions are not changed, eg, PreviousRun()?
The text was updated successfully, but these errors were encountered: