Register JobStateManager as singleton in DI container
JobStateManager is now added as a singleton service, initialized with the InitialJobState from WorkerOptions. This enables consistent state management across the application by providing a shared instance via dependency injection.
This commit is contained in:
@@ -11,6 +11,12 @@ public static class DependencyInjection
|
|||||||
public static IServiceCollection AddFinalizeDocumentJob(this IServiceCollection services, IConfiguration configuration)
|
public static IServiceCollection AddFinalizeDocumentJob(this IServiceCollection services, IConfiguration configuration)
|
||||||
{
|
{
|
||||||
services.Configure<WorkerOptions>(configuration.GetSection("Worker"));
|
services.Configure<WorkerOptions>(configuration.GetSection("Worker"));
|
||||||
|
services.AddSingleton(provider =>
|
||||||
|
{
|
||||||
|
var options = provider.GetRequiredService<IOptions<WorkerOptions>>().Value;
|
||||||
|
var manager = new JobStateManager(options.InitialJobState);
|
||||||
|
return manager;
|
||||||
|
});
|
||||||
services.AddScoped<FinalizeDocumentJob>();
|
services.AddScoped<FinalizeDocumentJob>();
|
||||||
services.AddScoped<ActionService>();
|
services.AddScoped<ActionService>();
|
||||||
services.AddSingleton<TempFiles>();
|
services.AddSingleton<TempFiles>();
|
||||||
|
|||||||
Reference in New Issue
Block a user