logstash-output-nsq 1.0.9 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/logstash/outputs/nsq.rb +41 -17
- data/logstash-output-nsq.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1181fa99eaf3d901a8105443850f7f8fdb84598
|
4
|
+
data.tar.gz: 6013ca1afc554012fe8ea85b6bb15e9d4ee620c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce2121499a39d4483c8898f64465aaf3ddfef373422466e9f81f8cf9d29aa00e2e1aded110db5b3985f839ca4c814bc163f7b7d2586227b46f12fc5a3d23b561
|
7
|
+
data.tar.gz: ad1aee4bf575a89637f74aa6242455da091435164496649e8f91f2c492137060262782c9fb2d7867b05b554ebfa1af95708a0e561ea6e227feb6c2d586bfeda4
|
data/lib/logstash/outputs/nsq.rb
CHANGED
@@ -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
|
-
|
6
|
+
declare_threadsafe!
|
7
|
+
config_name 'nsq'
|
6
8
|
|
7
|
-
|
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
|
-
|
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
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
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
|
-
|
81
|
-
|
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
|
+
|
data/logstash-output-nsq.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-output-nsq'
|
3
|
-
s.version = "1.0.
|
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"
|