logstash-output-nsq 1.0.9 → 1.0.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dd25f8e6bdfb09bc086e9facb0c799d7cc7ef624
4
- data.tar.gz: 3aa188a306b5f2f0a66661f817c383a8fc3720c0
3
+ metadata.gz: e1181fa99eaf3d901a8105443850f7f8fdb84598
4
+ data.tar.gz: 6013ca1afc554012fe8ea85b6bb15e9d4ee620c1
5
5
  SHA512:
6
- metadata.gz: 76df418a92a14e0aef8d7ad40796bf8541c8ee3fcb3493ac4d403647b0981521a6f2a847e7683aa10cf9458c6a65eb22eff0a17c78e0b8d52d135d0e6e566ce3
7
- data.tar.gz: 3762f904fc9b710b883d16586c961f67d73171333f1745696c4b4fe5b292863075a44abca245c764defcc6ead1bdcc5074e0d39bcc169c5f790a6c5a741f5710
6
+ metadata.gz: ce2121499a39d4483c8898f64465aaf3ddfef373422466e9f81f8cf9d29aa00e2e1aded110db5b3985f839ca4c814bc163f7b7d2586227b46f12fc5a3d23b561
7
+ data.tar.gz: ad1aee4bf575a89637f74aa6242455da091435164496649e8f91f2c492137060262782c9fb2d7867b05b554ebfa1af95708a0e561ea6e227feb6c2d586bfeda4
@@ -1,19 +1,25 @@
1
1
  require 'logstash/namespace'
2
2
  require 'logstash/outputs/base'
3
+ require 'java'
3
4
 
4
5
  class LogStash::Outputs::Nsq < LogStash::Outputs::Base
5
- config_name 'nsq'
6
+ declare_threadsafe!
7
+ config_name 'nsq'
6
8
 
7
- default :codec, 'json'
8
- config :nsqd, :validate => :string, :default => nil
9
- config :nsqlookupd, :validate => :array, :default => nil
10
- config :topic, :validate => :string, :required => true
11
- config :tls_v1, :validate => :boolean, :default => false
12
- config :tls_key, :validate => :string
13
- config :tls_cert, :validate => :string
9
+ default :codec, 'json'
14
10
 
11
+ default :codec, 'json'
12
+ config :nsqd, :validate => :string, :default => nil
13
+ config :nsqlookupd, :validate => :array, :default => nil
14
+ config :topic, :validate => :string, :required => true
15
+ config :tls_v1, :validate => :boolean, :default => false
16
+ config :tls_key, :validate => :string
17
+ config :tls_cert, :validate => :string
18
+
15
19
  public
16
20
  def register
21
+ @thread_batch_map = Concurrent::Hash.new
22
+
17
23
  require 'nsq'
18
24
  options = {
19
25
  :nsqlookupd => @nsqlookupd,
@@ -53,11 +59,11 @@ class LogStash::Outputs::Nsq < LogStash::Outputs::Base
53
59
  }
54
60
  end
55
61
  end # if
62
+
56
63
  @producer = Nsq::Producer.new(options)
57
- #@producer.connect
58
64
  @logger.info('Registering nsq producer', :nsqd => @nsqd, :nsqlookupd => @nsqlookupd, :topic => @topic)
59
65
  @codec.on_event do |event, data|
60
- write_to_nsq(event, data)
66
+ write_to_nsq(event, data)
61
67
  end
62
68
  end # def register
63
69
 
@@ -71,17 +77,35 @@ class LogStash::Outputs::Nsq < LogStash::Outputs::Base
71
77
  end # begin
72
78
  end # def send_to_nsq
73
79
 
74
- def receive(event)
75
- return unless output?(event)
76
- if event == LogStash::SHUTDOWN
77
- finished
78
- return
80
+ def prepare(record)
81
+ # This output is threadsafe, so we need to keep a batch per thread.
82
+ @thread_batch_map[Thread.current].add(record)
83
+ end
84
+
85
+ def multi_receive(events)
86
+ t = Thread.current
87
+ if !@thread_batch_map.include?(t)
88
+ @thread_batch_map[t] = java.util.ArrayList.new(events.size)
89
+ end
90
+
91
+ events.each do |event|
92
+ break if event == LogStash::SHUTDOWN
93
+ @codec.encode(event)
79
94
  end
80
- @codec.encode(event)
81
- end # def receive
95
+
96
+ batch = @thread_batch_map[t]
97
+ if batch.any?
98
+ retrying_send(batch)
99
+ batch.clear
100
+ end
101
+ end
82
102
 
83
103
  def close
84
104
  @logger.info('closing nsq producer')
85
105
  @producer.terminate
86
106
  end
107
+
108
+ private
109
+
87
110
  end #class LogStash::Outputs::Nsq
111
+
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-output-nsq'
3
- s.version = "1.0.9"
3
+ s.version = "1.0.10"
4
4
  s.licenses = ["Apache License (2.0)"]
5
5
  s.summary = "this logstash plugin outputs in a nsq topic"
6
6
  s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-output-nsq
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.9
4
+ version: 1.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthias Schneider