HangfireIO / HangfireIO/Hangfire
Obtain time in a recurring job
- Dominant language
- C#
- Stars
- 10.1k
- Forks
- 1.8k
- Avg merge
- 1h 19m
- Merged PRs (30d)
- 1
Description
Hi,
we'd like to use recurring jobs to generate scheduled reports. This means that inside a job we need to know for which time moment it was triggered. This way we can decide for which time interval we need to generate the report.
I realize that we may simply call DateTime.(Utc)Now at the start of the job handler, but that does not look like a reliable solution: the job might be right at some later point in time (especially, if it failed a couple of times or the server was down for some time). Even worse, it may result in two (or more) job instances doing the report for the same time interval (in case, the first job was delayed and then ran close in time to the second). Hope all this makes sense :)
In any case, this is what we need to avoid all those pitfalls: have access to the timestamp the job was scheduled for. Is there any way to obtain that?
Thanks in advance,
Dmytro.
Contributor guide
Research direction
Start by tracing how recurring jobs are scheduled and how their handlers receive execution context. Determine where the intended scheduled timestamp could be preserved and exposed, then verify behavior for delayed, retried, and overlapping executions. The issue names no files or tests, so the relevant entry points and acceptance tests must be identified first.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100