-
-
Notifications
You must be signed in to change notification settings - Fork 261
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
feat: configurable queue consummation delay #411
base: master
Are you sure you want to change the base?
feat: configurable queue consummation delay #411
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, thanks for the contribution!
I have a few improvements that I think will (a) help the code and (b) enable us to add some tests here.
Also, let's add some user documentation for this! In the file DocsV2/docs/Queuing/README.md
you can add the following to the Adjusting Consummation Delay
section:
Alternatively, you can adjust the consummation delay using AddQueue
:
services.AddQueue(queueOptions => {
// Consume queue every 5 seconds.
queueOptions.ConsummationDelay = 5;
});
:::tip
QueueOptions
will take precedence over your configuration file if both are defined.
:::
{ | ||
public class QueueOptions | ||
{ | ||
public int? ConsummationDelay { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add an XML comment here "This determines how often (in seconds) the queue host will consume all pending tasks."
if (this._queueOptions.ConsummationDelay.HasValue) return this._queueOptions.ConsummationDelay.Value; | ||
var configurationSection = this._configuration.GetSection("Coravel:Queue:ConsummationDelay"); | ||
bool couldParseDelay = int.TryParse(configurationSection.Value, out var parsedDelay); | ||
return couldParseDelay ? parsedDelay : 30; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that we now have an object handling queue options, I think it would be better to encapsulate this method inside of QueueOptions
and pass the IConfiguration
object as a param. So:
int consummationDelay = this._queueOptions.GetConsummationDelay(this._configuration);
Then, we could add a few tests against this method - probably under a new test file Src/UnitTests/CoravelUnitTests/Queuing/QueueOptionsTest.cs
.
Issue: #409