On Fri, Jan 18, 2013 at 5:07 PM, piavlo <notifications@github.com> wrote:

> In lib/logstash/inputs/redis.rb:
>
> > +      #A redis lua EVAL script to fetch a count of keys
> > +      #in case count is bigger than current items in queue whole queue will be returned without extra nil values
> > +      redis_script = <<EOF
> > +          local i = tonumber(ARGV[1])
> > +          local res = {}
> > +          local length = redis.call('llen',KEYS[1])
> > +          if length < i then i = length end
> > +          while (i > 0) do
> > +            table.insert(res, redis.call('lpop',KEYS[1]))
> > +            i = i-1
> > +          end
> > +          return res
> > +EOF
> > +      @redis_script_sha = redis.script(:load, redis_script)
> > +    end
> > +    redis
>
> oh avoiding return is an eventmachine habit :)
> I'm faily new to ruby , so I thought I did something conceptually wrong.
> I'll revert the code
> But again is there a real reason why you prefer separate redis connect
> method instead of doing it in register method? Since that would avoid the
> need for "@redis <https://github.com/redis> ||= connect" in listener_loop
> method.
>
> A separate connect method is necessary for two reasons:

1) the 'register' method is only invoked on logstash startup and never
again after that
2) redis can fail and give us desire to retry, so we need to be able to
connect again on failures.

-Jordan