Class: Fluent::NSQInput

Inherits:
Input
  • Object
show all
Defined in:
lib/fluent/plugin/in_nsq.rb

Instance Method Summary collapse

Constructor Details

#initializeNSQInput

Returns a new instance of NSQInput.



26
27
28
29
30
# File 'lib/fluent/plugin/in_nsq.rb', line 26

def initialize
  super
  require 'cool.io'
  require 'nsq'
end

Instance Method Details

#configure(conf) ⇒ Object



32
33
34
35
36
37
38
39
# File 'lib/fluent/plugin/in_nsq.rb', line 32

def configure(conf)
  super

  fail ConfigError, 'Missing nsqlookupd' unless @nsqlookupd
  fail ConfigError, 'Missing topic' unless @topic
  fail ConfigError, 'Missing channel' unless @channel
  fail ConfigError, 'in_flight needs to be bigger than 0' unless @in_flight > 0
end

#shutdownObject



54
55
56
57
58
# File 'lib/fluent/plugin/in_nsq.rb', line 54

def shutdown
  super
  @running = false
  @consumer.terminate
end

#startObject



41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/fluent/plugin/in_nsq.rb', line 41

def start
  super
  lookupds = @nsqlookupd.split(',')
  @consumer = Nsq::Consumer.new(
    nsqlookupd: lookupds,
    topic: @topic,
    channel: @channel,
    max_in_flight: @in_flight
  )
  @running = true
  @thread = Thread.new(&method(:consume))
end