HangfireIO / HangfireIO/Hangfire
Add support for resolving JobActivatorContext in AspNetCoreJobActivatorScope.
- Dominant language
- C#
- Stars
- 10.1k
- Forks
- 1.8k
- Avg merge
- 1h 19m
- Merged PRs (30d)
- 1
Description
It would be really nice to allow the JobActivatorContext to be injected into the constructor of a job when resolved inside the AspNetCoreJobActivatorScope. You could do the following:
* Pass the JobActivatorContext into the constructor of the AspNetCoreJobActivatorScope class.
* Instead of using the ServiceProvider directly off of the scope in the Resolve method of AspNetCoreJobActivatorScope, use the static method ActivatorUtilities.CreateInstance which allows you to specify additional parameters that can be injected along with what is currently available in the ServiceProvider.
It would be preferable to have the JobActivatorContext be inside the service provider as scoped, but I am sure that is a much bigger change.
If possible, could you also provider an interface for the JobActivatorContext instead of using the implemenation directly. It will be much easier for people to test they jobs if they can mock the JobActivatorContext.
Contributor guide
Research direction
Start by reading AspNetCoreJobActivatorScope, especially its constructor and Resolve method, and review how ActivatorUtilities.CreateInstance accepts additional parameters. Define the scope's handling of JobActivatorContext and the requested interface, then verify that jobs can receive the context and that the interface supports mocking in tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100