List pattern support #81
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add support for reading from list patterns such as
logstash.*
. Related issue: #49The motivation in our case is that we want to be able to see and control when individual applications produce spammy logs for whatever reason. In those situations, it's also important to be able to guarantee some level of fairness when consuming the queues, as opposed to having just one queue dominated by a potentially misbehaving application.
The implementation supports consuming single items per list using
LPOP
, as well as batched consuming using the sameEVAL
based logic as the regularlist
data_type
input.The logic is based on using a configurable-size concurrent-ruby thread pool. The main loop keeps polling the key pattern using the
KEYS
command and whenever the thread pool queue isn't full, posts a new job to the thread pool for consuming a single key. It keeps track of the keys currently queued and makes sure there's only one job per key at a time.I also did some refactoring and wanted to do more but decided to make this PR before going further in order to get some opinions.
So far I extracted the Redis connection logic as a MixIn - it's all in a single commit and can be reverted if need be.(edit: scratch that, I reverted this bit already, for now) What I'd like to do is make all the 3 different use cases (list, pattern list, PubSub) independent classes implementing an interface. It's currently quite messy with so much unrelated code in a single class.I'm not a Ruby developer (although I did gather input from colleagues who are) so let me know if there's anything silly, or if this somehow violates any logstash/elastic practices :)