From aa5c30a576b0b473c8c018cd017e2822db05c704 Mon Sep 17 00:00:00 2001 From: Dave Kaminski Date: Tue, 22 Nov 2016 15:00:32 -0600 Subject: [PATCH] Sleep duration as a config parameter --- lib/logstash/inputs/redis.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/logstash/inputs/redis.rb b/lib/logstash/inputs/redis.rb index 79bc51e..8c1472f 100644 --- a/lib/logstash/inputs/redis.rb +++ b/lib/logstash/inputs/redis.rb @@ -17,8 +17,6 @@ # newer. Anything older does not support the operations used by batching. # module LogStash module Inputs class Redis < LogStash::Inputs::Threadable - BATCH_EMPTY_SLEEP = 0.25 - config_name "redis" default :codec, "json" @@ -49,6 +47,9 @@ module LogStash module Inputs class Redis < LogStash::Inputs::Threadable # The number of events to return from Redis using EVAL. config :batch_count, :validate => :number, :default => 125 + # The number of seconds to sleep if Redis list is empty + config :sleep_sec, :validate => :number, :default => 0.25 + public # public API # use to store a proc that can provide a redis instance or mock @@ -192,7 +193,7 @@ def list_batch_listener(redis, output_queue) end if results.size.zero? - sleep BATCH_EMPTY_SLEEP + sleep @sleep_sec end # Below is a commented-out implementation of 'batch fetch'