Skip to content

Support rate-limited item insertion #9

@JOT85

Description

@JOT85

This was requested by @nathanwl88

I propose adding a wrapper around the work queue that would have essentially the same methods, except that the method for adding an item takes both an item and a new rate limiting tag (a string).

Each rate limiting tag would have an optional rate limit (in items per second, items per minute, or some similar unit).

If the rate of item insertion exceeds the limit, new items would be placed in a separate queue, and only added into the main queue at the rate specified by the rate limit.

Example

Let's suppose there are two rate limiting tags, foo (with a rate limit of 10 items per minute) and bar (with a rate limit of 20 items per minute).

In the first minute, if 15 items are added with tag foo, and a further 30 with tag bar, then the first 10 with the tag foo would enter the main queue, along with the first 20 with the tag `bar.

Then, in the second minute, the overflowing items from the previous minute are added. If 10 items were added with the foo tag, 5 of those would end up in the main queue (after those from the first minute).

Finally, in the third minute, the final 5 items with the foo tag would be added to the main queue.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions