Class: LogStash::Outputs::Nsq

Inherits:
Base
  • Object
show all
Defined in:
lib/logstash/outputs/nsq.rb

Instance Method Summary collapse

Instance Method Details

#closeObject



72
73
74
75
# File 'lib/logstash/outputs/nsq.rb', line 72

def close
  @logger.info('closing nsq producer')
  @producer.terminate
end

#multi_receive_encoded(encoded) ⇒ Object

def write_to_nsq



66
67
68
69
70
# File 'lib/logstash/outputs/nsq.rb', line 66

def multi_receive_encoded(encoded)
  encoded.each do |event,data|
    write_to_nsq(data)
  end
end

#registerObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/logstash/outputs/nsq.rb', line 18

def register
  options = {
      :nsqlookupd => @nsqlookupd,
      :topic => @topic,
      :tls_v1 => @tls_v1
  }
  # overwrite nsqlookupd options if client certificate validation is used:
  # this is very dirty. please fix 
  if @tls_key and @tls_cert
    options = {
        :nsqlookupd => @nsqlookupd,
        :topic => @topic,
        :tls_v1 => @tls_v1,
        :tls_context => {
         key: @tls_key,
         certificate: @tls_cert
        }
    }
  end
  # overwrite options if no nsqlookupd is used:
  if nsqlookupd == []
    if @tls_key and @tls_cert
      options = {
          :nsqd => @nsqd,
          :topic => @topic,
          :tls_v1 => @tls_v1,
          :tls_context => {
           key: @tls_key,
           certificate: @tls_cert
          }
      }
    else
      options = {
          :nsqd => @nsqd,
          :topic => @topic,
          :tls_v1 => @tls_v1
      }
    end
  end # if

  @producer = Nsq::Producer.new(options)
  @logger.info('Registering nsq producer', :nsqd => @nsqd, :nsqlookupd => @nsqlookupd, :topic => @topic)
end

#write_to_nsq(payload) ⇒ Object

def register



62
63
64
# File 'lib/logstash/outputs/nsq.rb', line 62

def write_to_nsq(payload)
  @producer.write(payload)
end