OrchardCMS / OrchardCore

Orchard Core is an open-source modular and multi-tenant application framework built with ASP.NET Core, and a content management system (CMS) built on top of that framework.
https://orchardcore.net
BSD 3-Clause "New" or "Revised" License
7.45k stars 2.41k forks source link

Make the polling time and min idle time of `ModularBackgroundService` configurable #17031

Closed Piedone closed 6 days ago

Piedone commented 1 week ago

Is your feature request related to a problem?

ModularBackgroundService executes background tasks in one-minute batches:

https://github.com/OrchardCMS/OrchardCore/blob/0917712993664113585516bca6b06149c3af7031/src/OrchardCore/OrchardCore/Modules/ModularBackgroundService.cs#L19

Additionally, there's a 10-second idle time between batches:

https://github.com/OrchardCMS/OrchardCore/blob/0917712993664113585516bca6b06149c3af7031/src/OrchardCore/OrchardCore/Modules/ModularBackgroundService.cs#L20

Neither of these are configurable, which prevents customizing background execution, forcing you to wait at least 1m 10s for a background task. Our particular use case at hand is for UI testing, where we have to wait for background tasks instead of being able to tell to execute them faster.

Describe the solution you'd like

Have IOptions configuration for both values.

Describe alternatives you've considered

If somehow these delays would use IClock internally then that would allow the UI testing use case too (since we can have a test-specific implementation that forwards time, what we actually have). It wouldn't help in other cases, though.