logstash-input-zeromq 2.0.4 → 3.0.0
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/CHANGELOG.md +9 -1
- data/CONTRIBUTORS +1 -0
- data/Gemfile +3 -1
- data/LICENSE +1 -1
- data/README.md +12 -3
- data/lib/logstash/inputs/zeromq.rb +51 -35
- data/logstash-input-zeromq.gemspec +4 -4
- data/spec/inputs/zeromq_spec.rb +52 -0
- data/spec/integration/zeromq_spec.rb +7 -2
- data/spec/spec_helper.rb +2 -9
- data/spec/support/client.rb +2 -2
- metadata +26 -25
- data/lib/logstash/util/zeromq.rb +0 -46
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 150429261e93e326c4af010caefb4ca3811d6624
|
4
|
+
data.tar.gz: 5af0979b436ffbfd933f38a2e78391355ed8f367
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6707e2ddb978dcca1deb114129f1970769a5fedb1a1532ac0dfb6b5c049a1a59afe5b5c28f3d0dd519efd85e200373863140ae8b7733bc36c852a5e68abda03b
|
7
|
+
data.tar.gz: c2b48f30b7652ed4e54fe529097d43dbcab0b64a26ae65abddfbefcf54a75a661709fd22899b4b5c6ca73d67b6685b9ad121d83069d6ff7f6d62ebd35afec763
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,17 @@
|
|
1
|
+
## 3.0.0
|
2
|
+
- Update the plugin to the version 2.0 of the plugin api, this change is required for Logstash 5.0 compatibility. See https://github.com/elastic/logstash/issues/5141
|
3
|
+
# 2.1.0
|
4
|
+
- Depend on logstash-mixin-zeromq, remove lib/logstash/util/zeromq
|
5
|
+
- Adapt test usage to be friendly with the way we run LS core default plugins test
|
6
|
+
- Fix plugin consumes 100% cpu
|
7
|
+
- Properly set topic field in pubsub topology
|
8
|
+
- Support multiple message frames
|
1
9
|
# 2.0.4
|
2
10
|
- Depend on logstash-core-plugin-api instead of logstash-core, removing the need to mass update plugins on major releases of logstash
|
3
11
|
# 2.0.3
|
4
12
|
- New dependency requirements for logstash-core for the 5.0 release
|
5
13
|
## 2.0.0
|
6
|
-
- Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully,
|
14
|
+
- Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully,
|
7
15
|
instead of using Thread.raise on the plugins' threads. Ref: https://github.com/elastic/logstash/pull/3895
|
8
16
|
- Dependency on logstash-core update to 2.0
|
9
17
|
|
data/CONTRIBUTORS
CHANGED
@@ -8,6 +8,7 @@ Contributors:
|
|
8
8
|
* Pier-Hugues Pellerin (ph)
|
9
9
|
* Richard Pijnenburg (electrical)
|
10
10
|
* Suyog Rao (suyograo)
|
11
|
+
* Avishai Ish-Shalom (avishai-ish-shalom)
|
11
12
|
|
12
13
|
Note: If you've sent us patches, bug reports, or otherwise contributed to
|
13
14
|
Logstash, and you aren't on the list above and want to be, please let us know
|
data/Gemfile
CHANGED
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# Logstash Plugin
|
2
2
|
|
3
|
-
[](http://build-eu-00.elastic.co/view/LS%20Plugins/view/LS%20Inputs/job/logstash-plugin-input-zeromq-unit/)
|
3
|
+
[](https://travis-ci.org/logstash-plugins/logstash-input-zeromq)
|
5
4
|
|
6
5
|
This is a plugin for [Logstash](https://github.com/elastic/logstash).
|
7
6
|
|
@@ -56,7 +55,12 @@ gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
|
|
56
55
|
```
|
57
56
|
- Install plugin
|
58
57
|
```sh
|
58
|
+
# Logstash 2.3 and higher
|
59
|
+
bin/logstash-plugin install --no-verify
|
60
|
+
|
61
|
+
# Prior to Logstash 2.3
|
59
62
|
bin/plugin install --no-verify
|
63
|
+
|
60
64
|
```
|
61
65
|
- Run Logstash with your plugin
|
62
66
|
```sh
|
@@ -74,7 +78,12 @@ gem build logstash-filter-awesome.gemspec
|
|
74
78
|
```
|
75
79
|
- Install the plugin from the Logstash home
|
76
80
|
```sh
|
77
|
-
|
81
|
+
# Logstash 2.3 and higher
|
82
|
+
bin/logstash-plugin install --no-verify
|
83
|
+
|
84
|
+
# Prior to Logstash 2.3
|
85
|
+
bin/plugin install --no-verify
|
86
|
+
|
78
87
|
```
|
79
88
|
- Start Logstash and proceed to test the plugin
|
80
89
|
|
@@ -8,7 +8,7 @@ require "socket"
|
|
8
8
|
# You need to have the 0mq 2.1.x library installed to be able to use
|
9
9
|
# this input plugin.
|
10
10
|
#
|
11
|
-
# The default settings will create a subscriber binding to `tcp://127.0.0.1:2120`
|
11
|
+
# The default settings will create a subscriber binding to `tcp://127.0.0.1:2120`
|
12
12
|
# waiting for connecting publishers.
|
13
13
|
#
|
14
14
|
class LogStash::Inputs::ZeroMQ < LogStash::Inputs::Base
|
@@ -46,13 +46,19 @@ class LogStash::Inputs::ZeroMQ < LogStash::Inputs::Base
|
|
46
46
|
# You can specify multiple topics here
|
47
47
|
config :topic, :validate => :array
|
48
48
|
|
49
|
+
# Event topic field
|
50
|
+
# This is used for the `pubsub` topology only
|
51
|
+
# When a message is received on a topic, the topic name on which
|
52
|
+
# the message was received will saved in this field.
|
53
|
+
config :topic_field, :validate => :string, :default => "topic"
|
54
|
+
|
49
55
|
# mode
|
50
56
|
# server mode binds/listens
|
51
57
|
# client mode connects
|
52
58
|
config :mode, :validate => ["server", "client"], :default => "server"
|
53
59
|
|
54
60
|
# sender
|
55
|
-
# overrides the sender to
|
61
|
+
# overrides the sender to
|
56
62
|
# set the source of the event
|
57
63
|
# default is `zmq+topology://type/`
|
58
64
|
config :sender, :validate => :string
|
@@ -68,18 +74,30 @@ class LogStash::Inputs::ZeroMQ < LogStash::Inputs::Base
|
|
68
74
|
# * `ZMQ::IDENTITY` - named queues
|
69
75
|
# * `ZMQ::SWAP_SIZE` - space for disk overflow
|
70
76
|
#
|
71
|
-
#
|
72
|
-
|
77
|
+
# Example:
|
78
|
+
# [source,ruby]
|
79
|
+
# sockopt => {
|
80
|
+
# "ZMQ::HWM" => 50
|
81
|
+
# "ZMQ::IDENTITY" => "my_named_queue"
|
82
|
+
# }
|
83
|
+
#
|
84
|
+
# defaults to: `sockopt => { "ZMQ::RCVTIMEO" => "1000" }`, which has the effect of "interrupting"
|
85
|
+
# the recv operation at least once every second to allow for properly shutdown handling.
|
86
|
+
config :sockopt, :validate => :hash, :default => { "ZMQ::RCVTIMEO" => "1000" }
|
73
87
|
|
74
88
|
public
|
75
89
|
def register
|
76
90
|
require "ffi-rzmq"
|
77
|
-
require "logstash/
|
78
|
-
self.class.send(:include, LogStash::
|
91
|
+
require "logstash/plugin_mixins/zeromq"
|
92
|
+
self.class.send(:include, LogStash::PluginMixins::ZeroMQ)
|
93
|
+
@host = Socket.gethostname
|
94
|
+
init_socket
|
95
|
+
end # def register
|
79
96
|
|
97
|
+
def init_socket
|
80
98
|
case @topology
|
81
99
|
when "pair"
|
82
|
-
zmq_const = ZMQ::PAIR
|
100
|
+
zmq_const = ZMQ::PAIR
|
83
101
|
when "pushpull"
|
84
102
|
zmq_const = ZMQ::PULL
|
85
103
|
when "pubsub"
|
@@ -110,8 +128,7 @@ class LogStash::Inputs::ZeroMQ < LogStash::Inputs::Base
|
|
110
128
|
end
|
111
129
|
end
|
112
130
|
end
|
113
|
-
|
114
|
-
end # def register
|
131
|
+
end
|
115
132
|
|
116
133
|
def close
|
117
134
|
begin
|
@@ -127,36 +144,12 @@ class LogStash::Inputs::ZeroMQ < LogStash::Inputs::Base
|
|
127
144
|
end # def server?
|
128
145
|
|
129
146
|
def run(output_queue)
|
130
|
-
host = Socket.gethostname
|
131
147
|
begin
|
132
148
|
while !stop?
|
133
|
-
|
134
|
-
# Get the first part as the msg
|
135
|
-
m1 = ""
|
136
|
-
rc = @zsocket.recv_string(m1, ZMQ::DONTWAIT)
|
137
|
-
next if rc == -1 && ZMQ::Util.errno == ZMQ::EAGAIN
|
138
|
-
error_check(rc, "in recv_string")
|
139
|
-
|
140
|
-
@logger.debug("ZMQ receiving", :event => m1)
|
141
|
-
msg = m1
|
142
|
-
# If we have more parts, we'll eat the first as the topic
|
143
|
-
# and set the message to the second part
|
144
|
-
if @zsocket.more_parts?
|
145
|
-
@logger.debug("Multipart message detected. Setting @message to second part. First part was: #{m1}")
|
146
|
-
m2 = ''
|
147
|
-
rc2 = @zsocket.recv_string(m2)
|
148
|
-
error_check(rc2, "in recv_string")
|
149
|
-
@logger.debug("ZMQ receiving", :event => m2)
|
150
|
-
msg = m2
|
151
|
-
end
|
152
|
-
@codec.decode(msg) do |event|
|
153
|
-
event["host"] ||= host
|
154
|
-
decorate(event)
|
155
|
-
output_queue << event
|
156
|
-
end
|
149
|
+
handle_message(output_queue)
|
157
150
|
end
|
158
151
|
rescue => e
|
159
|
-
@logger.debug("ZMQ Error", :subscriber => @zsocket,
|
152
|
+
@logger.debug? && @logger.debug("ZMQ Error", :subscriber => @zsocket,
|
160
153
|
:exception => e)
|
161
154
|
retry
|
162
155
|
end # begin
|
@@ -167,4 +160,27 @@ class LogStash::Inputs::ZeroMQ < LogStash::Inputs::Base
|
|
167
160
|
id = @address.first.clone
|
168
161
|
end
|
169
162
|
|
163
|
+
def handle_message(output_queue)
|
164
|
+
# Here's the unified receiver
|
165
|
+
more = true
|
166
|
+
parts = []
|
167
|
+
rc = @zsocket.recv_strings(parts)
|
168
|
+
error_check(rc, "in recv_strings", true)
|
169
|
+
return unless ZMQ::Util.resultcode_ok?(rc)
|
170
|
+
|
171
|
+
if @topology == "pubsub" && parts.length > 1
|
172
|
+
# assume topic is a simple string
|
173
|
+
topic, *parts = parts
|
174
|
+
else
|
175
|
+
topic = nil
|
176
|
+
end
|
177
|
+
parts.each do |msg|
|
178
|
+
@codec.decode(msg) do |event|
|
179
|
+
event.set("host", event.get("host") || @host)
|
180
|
+
event.set(@topic_field, topic.force_encoding('UTF-8')) unless topic.nil?
|
181
|
+
decorate(event)
|
182
|
+
output_queue << event
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
170
186
|
end # class LogStash::Inputs::ZeroMQ
|
@@ -1,10 +1,10 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-input-zeromq'
|
4
|
-
s.version = '
|
4
|
+
s.version = '3.0.0'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "$summary"
|
7
|
-
s.description = "This gem is a
|
7
|
+
s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
|
8
8
|
s.authors = ["Elastic"]
|
9
9
|
s.email = 'info@elastic.co'
|
10
10
|
s.homepage = "http://www.elastic.co/guide/en/logstash/current/index.html"
|
@@ -20,9 +20,9 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "input" }
|
21
21
|
|
22
22
|
# Gem dependencies
|
23
|
-
s.add_runtime_dependency "logstash-core-plugin-api", "~>
|
23
|
+
s.add_runtime_dependency "logstash-core-plugin-api", "~> 2.0"
|
24
|
+
s.add_runtime_dependency "logstash-mixin-zeromq", ">= 2.0.1"
|
24
25
|
|
25
26
|
s.add_runtime_dependency 'logstash-codec-json'
|
26
|
-
s.add_runtime_dependency 'ffi-rzmq', '~> 2.0.4'
|
27
27
|
s.add_development_dependency 'logstash-devutils'
|
28
28
|
end
|
data/spec/inputs/zeromq_spec.rb
CHANGED
@@ -2,6 +2,23 @@
|
|
2
2
|
require_relative "../spec_helper"
|
3
3
|
require "logstash/plugin"
|
4
4
|
require "logstash/event"
|
5
|
+
require "securerandom"
|
6
|
+
|
7
|
+
def send_mock_messages(messages, &block)
|
8
|
+
socket = double("socket")
|
9
|
+
expect(socket).to receive(:recv_strings) do |arr|
|
10
|
+
messages.each do |msg|
|
11
|
+
msg.each do |frame|
|
12
|
+
arr << frame
|
13
|
+
end
|
14
|
+
end
|
15
|
+
0
|
16
|
+
end
|
17
|
+
plugin.instance_variable_set(:@zsocket, socket)
|
18
|
+
q = []
|
19
|
+
plugin.send(:handle_message, q)
|
20
|
+
q
|
21
|
+
end
|
5
22
|
|
6
23
|
describe LogStash::Inputs::ZeroMQ, :zeromq => true do
|
7
24
|
|
@@ -24,4 +41,39 @@ describe LogStash::Inputs::ZeroMQ, :zeromq => true do
|
|
24
41
|
end
|
25
42
|
|
26
43
|
end
|
44
|
+
|
45
|
+
context "pubsub" do
|
46
|
+
topic_field = SecureRandom.hex
|
47
|
+
let(:plugin) { LogStash::Plugin.lookup("input", "zeromq").new({"topology" => "pubsub", "topic_field" => topic_field}) }
|
48
|
+
|
49
|
+
before do
|
50
|
+
allow(plugin).to receive(:init_socket)
|
51
|
+
plugin.register
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should set the topic field with multiple message frames" do
|
55
|
+
events = send_mock_messages([["topic", '{"message": "message"}', '{"message": "message2"}']])
|
56
|
+
expect(events.first.get(topic_field)).to eq("topic")
|
57
|
+
expect(events.first.get("message")).to eq("message")
|
58
|
+
expect(events[1].get("message")).to eq("message2")
|
59
|
+
expect(events[1].get(topic_field)).to eq("topic")
|
60
|
+
expect(events.length).to eq(2)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context "pushpull" do
|
65
|
+
let(:plugin) { LogStash::Plugin.lookup("input", "zeromq").new({ "topology" => "pushpull" }) }
|
66
|
+
|
67
|
+
before do
|
68
|
+
allow(plugin).to receive(:init_socket)
|
69
|
+
plugin.register
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should receive multiple frames" do
|
73
|
+
events = send_mock_messages([['{"message": "message"}', '{"message": "message2"}']])
|
74
|
+
expect(events.first.get("message")).to eq("message")
|
75
|
+
expect(events[1].get("message")).to eq("message2")
|
76
|
+
expect(events.length).to eq(2)
|
77
|
+
end
|
78
|
+
end
|
27
79
|
end
|
@@ -2,9 +2,12 @@
|
|
2
2
|
require_relative "../spec_helper"
|
3
3
|
require "logstash/plugin"
|
4
4
|
require "logstash/event"
|
5
|
+
require "json"
|
5
6
|
|
6
7
|
describe LogStash::Inputs::ZeroMQ, :integration => true do
|
7
8
|
|
9
|
+
let(:helpers) { ZeroMQHelpers.new }
|
10
|
+
|
8
11
|
describe "receive events" do
|
9
12
|
|
10
13
|
let(:nevents) { 10 }
|
@@ -16,10 +19,11 @@ describe LogStash::Inputs::ZeroMQ, :integration => true do
|
|
16
19
|
end
|
17
20
|
|
18
21
|
let(:events) do
|
19
|
-
input(conf, nevents) do
|
22
|
+
helpers.input(conf, nevents) do
|
20
23
|
client = ZeroMQClient.new("127.0.0.1", port)
|
21
24
|
nevents.times do |value|
|
22
|
-
client.send("
|
25
|
+
client.send("TOPIC", ZMQ::SNDMORE)
|
26
|
+
client.send({"message" => "data #{value}"}.to_json)
|
23
27
|
end
|
24
28
|
client.close
|
25
29
|
end
|
@@ -27,6 +31,7 @@ describe LogStash::Inputs::ZeroMQ, :integration => true do
|
|
27
31
|
|
28
32
|
it "should receive the events" do
|
29
33
|
expect(events.count).to be(nevents)
|
34
|
+
expect(events.map(&:to_hash)).to all(include("topic" => "TOPIC"))
|
30
35
|
end
|
31
36
|
end
|
32
37
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -3,13 +3,7 @@ require "logstash/devutils/rspec/spec_helper"
|
|
3
3
|
require "logstash/inputs/zeromq"
|
4
4
|
require_relative "support/client"
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
def setup_clients(number_of_clients, port)
|
9
|
-
number_of_clients.times.inject([]) do |clients|
|
10
|
-
clients << ZeroMQClient.new(localhost, port)
|
11
|
-
end
|
12
|
-
end
|
6
|
+
class ZeroMQHelpers
|
13
7
|
|
14
8
|
def input(config, size, &block)
|
15
9
|
plugin = LogStash::Plugin.lookup("input", "zeromq").new(config)
|
@@ -31,7 +25,6 @@ module ZeroMQHelpers
|
|
31
25
|
end
|
32
26
|
|
33
27
|
RSpec.configure do |config|
|
34
|
-
config.
|
35
|
-
config.filter_run_excluding({ :zeromq => true, :integration => true })
|
28
|
+
# config.filter_run_excluding({ :zeromq => true, :integration => true })
|
36
29
|
config.order = :random
|
37
30
|
end
|
data/spec/support/client.rb
CHANGED
metadata
CHANGED
@@ -1,72 +1,74 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-input-zeromq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
+
name: logstash-core-plugin-api
|
14
15
|
requirement: !ruby/object:Gem::Requirement
|
15
16
|
requirements:
|
16
17
|
- - "~>"
|
17
18
|
- !ruby/object:Gem::Version
|
18
|
-
version: '
|
19
|
-
name: logstash-core-plugin-api
|
20
|
-
prerelease: false
|
19
|
+
version: '2.0'
|
21
20
|
type: :runtime
|
21
|
+
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
+
name: logstash-mixin-zeromq
|
28
29
|
requirement: !ruby/object:Gem::Requirement
|
29
30
|
requirements:
|
30
31
|
- - ">="
|
31
32
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
33
|
-
name: logstash-codec-json
|
34
|
-
prerelease: false
|
33
|
+
version: 2.0.1
|
35
34
|
type: :runtime
|
35
|
+
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 2.0.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
+
name: logstash-codec-json
|
42
43
|
requirement: !ruby/object:Gem::Requirement
|
43
44
|
requirements:
|
44
|
-
- - "
|
45
|
+
- - ">="
|
45
46
|
- !ruby/object:Gem::Version
|
46
|
-
version:
|
47
|
-
name: ffi-rzmq
|
48
|
-
prerelease: false
|
47
|
+
version: '0'
|
49
48
|
type: :runtime
|
49
|
+
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
+
name: logstash-devutils
|
56
57
|
requirement: !ruby/object:Gem::Requirement
|
57
58
|
requirements:
|
58
59
|
- - ">="
|
59
60
|
- !ruby/object:Gem::Version
|
60
61
|
version: '0'
|
61
|
-
name: logstash-devutils
|
62
|
-
prerelease: false
|
63
62
|
type: :development
|
63
|
+
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
description: This gem is a
|
69
|
+
description: This gem is a Logstash plugin required to be installed on top of the
|
70
|
+
Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This
|
71
|
+
gem is not a stand-alone program
|
70
72
|
email: info@elastic.co
|
71
73
|
executables: []
|
72
74
|
extensions: []
|
@@ -79,7 +81,6 @@ files:
|
|
79
81
|
- NOTICE.TXT
|
80
82
|
- README.md
|
81
83
|
- lib/logstash/inputs/zeromq.rb
|
82
|
-
- lib/logstash/util/zeromq.rb
|
83
84
|
- logstash-input-zeromq.gemspec
|
84
85
|
- spec/inputs/zeromq_spec.rb
|
85
86
|
- spec/integration/zeromq_spec.rb
|
@@ -91,7 +92,7 @@ licenses:
|
|
91
92
|
metadata:
|
92
93
|
logstash_plugin: 'true'
|
93
94
|
logstash_group: input
|
94
|
-
post_install_message:
|
95
|
+
post_install_message:
|
95
96
|
rdoc_options: []
|
96
97
|
require_paths:
|
97
98
|
- lib
|
@@ -106,9 +107,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
107
|
- !ruby/object:Gem::Version
|
107
108
|
version: '0'
|
108
109
|
requirements: []
|
109
|
-
rubyforge_project:
|
110
|
-
rubygems_version: 2.
|
111
|
-
signing_key:
|
110
|
+
rubyforge_project:
|
111
|
+
rubygems_version: 2.5.1
|
112
|
+
signing_key:
|
112
113
|
specification_version: 4
|
113
114
|
summary: "$summary"
|
114
115
|
test_files:
|
data/lib/logstash/util/zeromq.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'ffi-rzmq'
|
3
|
-
require "logstash/namespace"
|
4
|
-
|
5
|
-
module LogStash::Util::ZeroMQ
|
6
|
-
# LOGSTASH-400
|
7
|
-
# see https://github.com/chuckremes/ffi-rzmq/blob/master/lib/ffi-rzmq/socket.rb#L93-117
|
8
|
-
STRING_OPTS = %w{IDENTITY SUBSCRIBE UNSUBSCRIBE}
|
9
|
-
|
10
|
-
def context
|
11
|
-
@context ||= ZMQ::Context.new
|
12
|
-
end
|
13
|
-
|
14
|
-
def setup(socket, address)
|
15
|
-
if server?
|
16
|
-
error_check(socket.bind(address), "binding to #{address}")
|
17
|
-
else
|
18
|
-
error_check(socket.connect(address), "connecting to #{address}")
|
19
|
-
end
|
20
|
-
@logger.info("0mq: #{server? ? 'connected' : 'bound'}", :address => address)
|
21
|
-
end
|
22
|
-
|
23
|
-
def error_check(rc, doing)
|
24
|
-
unless ZMQ::Util.resultcode_ok?(rc)
|
25
|
-
@logger.error("ZeroMQ error while #{doing}", { :error_code => rc })
|
26
|
-
raise "ZeroMQ Error while #{doing}"
|
27
|
-
end
|
28
|
-
end # def error_check
|
29
|
-
|
30
|
-
def setopts(socket, options)
|
31
|
-
options.each do |opt,value|
|
32
|
-
sockopt = opt.split('::')[1]
|
33
|
-
option = ZMQ.const_defined?(sockopt) ? ZMQ.const_get(sockopt) : ZMQ.const_missing(sockopt)
|
34
|
-
unless STRING_OPTS.include?(sockopt)
|
35
|
-
begin
|
36
|
-
Float(value)
|
37
|
-
value = value.to_i
|
38
|
-
rescue ArgumentError
|
39
|
-
raise "#{sockopt} requires a numeric value. #{value} is not numeric"
|
40
|
-
end
|
41
|
-
end # end unless
|
42
|
-
error_check(socket.setsockopt(option, value),
|
43
|
-
"while setting #{opt} == #{value}")
|
44
|
-
end # end each
|
45
|
-
end # end setopts
|
46
|
-
end # module LogStash::Util::ZeroMQ
|