Class: LogStash::Inputs::Redis

Inherits:
Base
  • Object
show all
Defined in:
lib/logstash/inputs/redis.rb

Instance Attribute Summary

Attributes inherited from Base

#logger

Instance Method Summary collapse

Methods inherited from Base

#receive, #tag

Constructor Details

#initialize(url, config = {}, &block) ⇒ Redis

Returns a new instance of Redis.



7
8
9
# File 'lib/logstash/inputs/redis.rb', line 7

def initialize(url, config={}, &block)
  super
end

Instance Method Details

#registerObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/logstash/inputs/redis.rb', line 11

def register
  _, @db, @queue = @url.path.split('/')
  puts @url.host, @url.port, @db, @queue
  EM.run do
    redis = EM::Protocols::Redis.connect :host => @url.host, :port => @url.port, :db => @db
    pop = lambda do
      redis.blpop @queue, 0 do |response|
        event = LogStash::Event.new({
          "@message" => response,
          "@type" => @type,
          "@tags" => @tags.clone,
        })
        event.source = @url
        @callback.call(event)
        pop.call
      end
    end
    pop.call
  end
end