coravel icon indicating copy to clipboard operation
coravel copied to clipboard

Fluent configurations

Open BOBx5 opened this issue 5 months ago • 3 comments

AS-IS

Currently, To use Coravel Queue, I have to use functions below

public void ConfigureServices(IServiceCollection services)
{
    services.AddQueue();
}
public static IApplicationBuilder UseCoravel(this IApplicationBuilder app)
{
    app.ApplicationServices.ConfigureQueue();
    return app;
}

TO-BE

1. Queue Consumption Delay with milliseconds

For better customizable options, I propose that the delay time can be set with milliseconds.

QueuingHost.cs

  • AS-IS

    public Task StartAsync(CancellationToken cancellationToken)
    {
        // ...
        this._timer = new Timer(
            (state) => this._signal.Release(), 
            null, 
            TimeSpan.Zero, 
            TimeSpan.FromSeconds(consummationDelay));
        // ...
    }
    
  • TO-BE

    public Task StartAsync(CancellationToken cancellationToken)
    {
        // ...
        this._timer = new Timer(
            (state) => this._signal.Release(), 
            null, 
            TimeSpan.Zero, 
            TimeSpan.FromMilliseconds(consummationDelay)); // Change to milliseconds
        // ...
    }
    

2. Add Extension Method for Queue Consummation Delay (or other options)

public void ConfigureServices(IServiceCollection services)
{
    services.AddQueue()
        .WithConsummationDelay(1000); // 1 second
}

BOBx5 avatar Sep 03 '24 03:09 BOBx5