diff --git a/framework/src/Volo.Abp.BackgroundJobs.Abstractions/Volo/Abp/BackgroundJobs/BackgroundJobOptions.cs b/framework/src/Volo.Abp.BackgroundJobs.Abstractions/Volo/Abp/BackgroundJobs/BackgroundJobOptions.cs index 23e2d6178e..4d2dd2885f 100644 --- a/framework/src/Volo.Abp.BackgroundJobs.Abstractions/Volo/Abp/BackgroundJobs/BackgroundJobOptions.cs +++ b/framework/src/Volo.Abp.BackgroundJobs.Abstractions/Volo/Abp/BackgroundJobs/BackgroundJobOptions.cs @@ -7,51 +7,14 @@ namespace Volo.Abp.BackgroundJobs { public Dictionary JobTypes { get; } - //TODO: Move options related to default backgroundjob manager to another class - /// /// Default: true. /// - public bool IsJobExecutionEnabled { get; set; } = true; - - /// - /// Interval between polling jobs from . - /// Default value: 5000 (5 seconds). - /// - public int JobPollPeriod { get; set; } - - /// - /// Maximum count of jobs to fetch from data store in one loop. - /// - public int MaxJobFetchCount { get; set; } = 1000; - - /// - /// Default duration (as seconds) for the first wait on a failure. - /// Default value: 60 (1 minutes). - /// - public int DefaultFirstWaitDuration { get; set; } - - /// - /// Default timeout value (as seconds) for a job before it's abandoned (). - /// Default value: 172,800 (2 days). - /// - public int DefaultTimeout { get; set; } - - /// - /// Default wait factor for execution failures. - /// This amount is multiplated by last wait time to calculate next wait time. - /// Default value: 2.0. - /// - public double DefaultWaitFactor { get; set; } + public bool IsEnabled { get; set; } = true; public BackgroundJobOptions() { JobTypes = new Dictionary(); - - JobPollPeriod = 5000; - DefaultFirstWaitDuration = 60; - DefaultTimeout = 172800; - DefaultWaitFactor = 2.0; } internal Type GetJobType(string jobName) diff --git a/framework/src/Volo.Abp.BackgroundJobs/Volo/Abp/BackgroundJobs/AbpBackgroundJobsModule.cs b/framework/src/Volo.Abp.BackgroundJobs/Volo/Abp/BackgroundJobs/AbpBackgroundJobsModule.cs index dadce7179a..ce60372a76 100644 --- a/framework/src/Volo.Abp.BackgroundJobs/Volo/Abp/BackgroundJobs/AbpBackgroundJobsModule.cs +++ b/framework/src/Volo.Abp.BackgroundJobs/Volo/Abp/BackgroundJobs/AbpBackgroundJobsModule.cs @@ -31,7 +31,7 @@ namespace Volo.Abp.BackgroundJobs public override void OnApplicationInitialization(ApplicationInitializationContext context) { var options = context.ServiceProvider.GetRequiredService>().Value; - if (options.IsJobExecutionEnabled) + if (options.IsEnabled) { context.ServiceProvider .GetRequiredService() diff --git a/framework/src/Volo.Abp.BackgroundJobs/Volo/Abp/BackgroundJobs/BackgroundJobWorker.cs b/framework/src/Volo.Abp.BackgroundJobs/Volo/Abp/BackgroundJobs/BackgroundJobWorker.cs index 07a52cbb50..ec881b690e 100644 --- a/framework/src/Volo.Abp.BackgroundJobs/Volo/Abp/BackgroundJobs/BackgroundJobWorker.cs +++ b/framework/src/Volo.Abp.BackgroundJobs/Volo/Abp/BackgroundJobs/BackgroundJobWorker.cs @@ -12,7 +12,7 @@ namespace Volo.Abp.BackgroundJobs { protected IBackgroundJobExecuter JobExecuter { get; } protected IBackgroundJobStore Store { get; } - protected BackgroundJobOptions Options { get; } + protected BackgroundJobWorkerOptions Options { get; } protected IClock Clock { get; } /// @@ -22,7 +22,7 @@ namespace Volo.Abp.BackgroundJobs IBackgroundJobStore store, AbpTimer timer, IBackgroundJobExecuter jobExecuter, - IOptions options, + IOptions options, IClock clock) : base(timer) { diff --git a/framework/src/Volo.Abp.BackgroundJobs/Volo/Abp/BackgroundJobs/BackgroundJobWorkerOptions.cs b/framework/src/Volo.Abp.BackgroundJobs/Volo/Abp/BackgroundJobs/BackgroundJobWorkerOptions.cs new file mode 100644 index 0000000000..f89bc40e67 --- /dev/null +++ b/framework/src/Volo.Abp.BackgroundJobs/Volo/Abp/BackgroundJobs/BackgroundJobWorkerOptions.cs @@ -0,0 +1,45 @@ +namespace Volo.Abp.BackgroundJobs +{ + public class BackgroundJobWorkerOptions + { + /// + /// Interval between polling jobs from . + /// Default value: 5000 (5 seconds). + /// + public int JobPollPeriod { get; set; } + + /// + /// Maximum count of jobs to fetch from data store in one loop. + /// Default: 1000. + /// + public int MaxJobFetchCount { get; set; } + + /// + /// Default duration (as seconds) for the first wait on a failure. + /// Default value: 60 (1 minutes). + /// + public int DefaultFirstWaitDuration { get; set; } + + /// + /// Default timeout value (as seconds) for a job before it's abandoned (). + /// Default value: 172,800 (2 days). + /// + public int DefaultTimeout { get; set; } + + /// + /// Default wait factor for execution failures. + /// This amount is multiplated by last wait time to calculate next wait time. + /// Default value: 2.0. + /// + public double DefaultWaitFactor { get; set; } + + public BackgroundJobWorkerOptions() + { + MaxJobFetchCount = 1000; + JobPollPeriod = 5000; + DefaultFirstWaitDuration = 60; + DefaultTimeout = 172800; + DefaultWaitFactor = 2.0; + } + } +} diff --git a/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp/DemoAppModule.cs b/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp/DemoAppModule.cs index 1a80ab9887..a1016fdb44 100644 --- a/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp/DemoAppModule.cs +++ b/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp/DemoAppModule.cs @@ -36,7 +36,7 @@ namespace Volo.Abp.BackgroundJobs.DemoApp }); }); - context.Services.Configure(options => + context.Services.Configure(options => { //Configure for fast running options.JobPollPeriod = 1000; diff --git a/modules/background-jobs/test/Volo.Abp.BackgroundJobs.TestBase/Volo.Abp/BackgroundJobs/BackgroundJobsTestBaseModule.cs b/modules/background-jobs/test/Volo.Abp.BackgroundJobs.TestBase/Volo.Abp/BackgroundJobs/BackgroundJobsTestBaseModule.cs index 310a819205..b996350029 100644 --- a/modules/background-jobs/test/Volo.Abp.BackgroundJobs.TestBase/Volo.Abp/BackgroundJobs/BackgroundJobsTestBaseModule.cs +++ b/modules/background-jobs/test/Volo.Abp.BackgroundJobs.TestBase/Volo.Abp/BackgroundJobs/BackgroundJobsTestBaseModule.cs @@ -15,7 +15,7 @@ namespace Volo.Abp.BackgroundJobs { context.Services.Configure(options => { - options.IsJobExecutionEnabled = false; + options.IsEnabled = false; }); context.Services.AddAssemblyOf();