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

feat: configurable queue consummation delay #411

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

kmakris23
Copy link

Issue: #409

Copy link
Owner

@jamesmh jamesmh left a 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; }
Copy link
Owner

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."

Comment on lines +42 to 45
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;
Copy link
Owner

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.

@jamesmh jamesmh self-assigned this Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants