-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Make JobActivatorScope
instance available in the PerformContext
#2492
Comments
Also, please change the public override object Resolve(Type type) {
return ActivatorUtilities.GetServiceOrCreateInstance( _lifetimeScope.Resolve<IServiceProvider>(), type);
} |
Could you share more details regarding the new callback API that's missing? E.g. what's the current behavior, what's expected behavior, what compiler error or exception you see with the current implementation? |
The new API was added after the latest release. |
May I ask you to be more specific regarding the new API, e.g. which type, method and parameters are required in your case? Otherwise it's not possible to even test the resulting changes. |
Sorry for confusion, what I'm asking is just to release the latest version of public override object Resolve(Type type) {
return ActivatorUtilities.GetServiceOrCreateInstance( _lifetimeScope.Resolve<IServiceProvider>(), type);
} Another feature request, would you please add |
Hello, I have released Hangfire.Autofac 2.7.0 yesterday with the new scope configuration action feature. However, we can't add I will also think about |
Thanks |
Not quite, Hangfire.Autofac doesn't depend on ASP.NET Core at all, that |
Hm, just realized that public sealed class DependencyInjectionExample : IServerFilter
{
private readonly IServiceProvider _serviceProvider;
public DependencyInjectionExample(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
}
public void OnPerforming(PerformingContext context)
{
var service = _serviceProvider.GetRequiredService<IMyService>();
}
public void OnPerformed(PerformedContext context)
{
}
} services.AddHangfire((provider, configuration) => configuration
.UseFilter(new DependencyInjectionExample(provider)) |
You are right, it doesn't depend (in |
The filter here uses |
Good point, @jvmlet! Unfortunately, the activator scope is created after |
PerformContext
PerformContext
JobActivatorScope
instance available in the PerformContext
The goal here is to make it accessible also in IServerFilter implementations, as a property in the PerformContext class to allow them resolving the same services as the background job itself. While it doesn’t make much sense with regular IoC containers, some advanced ones, like Autofac that allows registering custom services for created scopes, can receive big improvements. Also, ASP.NET Core’s IoC container implementation should also reach this point sooner or later, given the importance of this feature. |
OK, so if scope will be created before executing |
Please release the latest
Hangfire.Autofac
.Need the configure action callback API that was recently added.
Thanks.
The text was updated successfully, but these errors were encountered: