Skip to content
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

Add an overload for AddHangfireServer utilizing IServiceProvider #1800

Merged
merged 1 commit into from
Mar 19, 2021

Conversation

penenkel
Copy link
Contributor

This allows the configuration of BackgroundJobServerOptions to be based on other services, options, etc..

While there exists the workaround of registering the BackgroundJobServerOptions manually

services.AddSingleton(provider => {
var other = provider.getRequiredService<OtherOptions>();
return new BackgroundJobServerOptions
{
    Queues = new[] { "default", "misc", other.SomeQueueName},
    WorkerCount = 1,
};
});
services.AddHangfireServer();

This fails if one wants to register multiple HangfireServer with differing configurations (all based on some other service/options).

…ServiceProvider

This allows the configuration of `BackgroundJobServerOptions` to be based on other services, options, etc..

While there exists the workaround of registering the `BackgroundJobServerOptions` manually
```
services.AddSingleton(provider => {
var other = provider.getRequiredService<OtherOptions>();
return new BackgroundJobServerOptions
{
    Queues = new[] { "default", "misc", other.SomeQueueName},
    WorkerCount = 1,
};
});
services.AddHangfireServer();
```
This fails if one wants to register multiple HangfireServer with differing configurations (all based on some other service/options).
@odinserj
Copy link
Member

Thanks @penenkel, will release this in version 1.7.20 today.

@odinserj odinserj merged commit bd95751 into HangfireIO:master Mar 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

2 participants