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

[FEATURE REQUEST] Support for Fixed-Length Queues in Asynq #869

Open
FogDong opened this issue Apr 23, 2024 · 1 comment
Open

[FEATURE REQUEST] Support for Fixed-Length Queues in Asynq #869

FogDong opened this issue Apr 23, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@FogDong
Copy link

FogDong commented Apr 23, 2024

Is your feature request related to a problem? Please describe.
In many applications, particularly those involving resource-constrained environments or systems where old tasks need to be automatically discarded, having the ability to maintain fixed-length queues is crucial. This feature would allow developers to set a maximum size on queues, ensuring that the queue does not exceed a certain number of tasks. This is particularly useful for maintaining the latest N tasks and automatically discarding older tasks when new ones arrive.

Describe the solution you'd like
I propose that Asynq supports an option to limit the size of task queues. When a queue reaches its maximum size, the system should automatically remove the oldest task(s) upon the addition of new tasks. This would ensure that the queue remains at a fixed length.

The implementation could involve:

  1. Extending the QueueConfig struct to include a new field, MaxSize, which defines the maximum number of tasks the queue can hold.
  2. Modifying the task enqueue logic to check the current queue size against MaxSize. If the queue size is at its maximum, the oldest task(s) would be dequeued or dropped before the new task is enqueued.
  3. Providing configuration options in the Asynq server settings to enable and configure this feature per queue.

Describe alternatives you've considered

Additional context
If this feature is accepted by the Asynq community, I would be very interested in contributing to its development. I believe this feature would not only benefit my use case but also be a valuable addition for many other users facing similar requirements.

@FogDong FogDong added the enhancement New feature or request label Apr 23, 2024
@sanudatta11
Copy link

what happens to the old tasks in the queue, are u thinking of a DLQ approach where these tasks go to die or just removed completely with no trace?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants