HangfireIO / HangfireIO/Hangfire

Add a Result property to Job or JobData class

Open
#1,245 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
10.1k
Forks
1.8k
Avg merge
1h 19m
Merged PRs (30d)
1

Description

I'm using this code to check whether a job has completed successfully or not.

using (var conn = JobStorage.Current.GetConnection()) {
  var data = conn.GetJobData(Id);
  if (data?.State == SucceededState.StateName) {
    //Here, I need to get the result
  }
}

When a job is successfully completed, I need to get its result but there's no Result property in the JobData or Job classes. What I'm doing, instead, is the following, which I think is not efficient.

var succeededJob = JobStorage.Current.GetMonitoringApi().SucceededJobs(0, int.MaxValue).FirstOrDefault(j => j.Key == Id);
var jobResult = succeededJob.Value.Result;

How can I efficiently get a job result by its job id?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with JobData, Job, GetJobData, and the SucceededJobs entry points shown in the issue to understand how completed job results are exposed. Determine the API path for retrieving a result by job ID without scanning all succeeded jobs; done means the result is available through the appropriate job or storage API and is covered by relevant tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.