logstash-mixin-zeromq 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +2 -0
- data/CONTRIBUTORS +16 -0
- data/Gemfile +2 -0
- data/LICENSE +13 -0
- data/NOTICE.TXT +5 -0
- data/README.md +7 -0
- data/lib/logstash/plugin_mixins/zeromq.rb +46 -0
- data/logstash-util-zeromq.gemspec +26 -0
- data/spec/plugin_mixins/zeromq_spec.rb +95 -0
- metadata +115 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 581a303492a25d46f0bd462e8cddf2464d2cea18
|
4
|
+
data.tar.gz: 460addf350a60201f1230e14c9450fcca928fb2f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 01251b1a3cf3e13d59939e2f3bbe79b8139177c92777664845dd18e73747d588cece9c2402492864f7c16e4f9ad6c2a1674c9e8e83c166122e3d6528ee47953a
|
7
|
+
data.tar.gz: 4cfd55e56dc3623912e5ddb5502159553e7b79347f1ecab4b86e57beefad84d14c1a342263299b0606996e9d0648e6f841d11fd5ab041e04c00d2d463f045e74
|
data/CHANGELOG.md
ADDED
data/CONTRIBUTORS
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
The following is a list of people who have contributed ideas, code, bug
|
2
|
+
reports, or in general have helped logstash along its way.
|
3
|
+
|
4
|
+
Contributors:
|
5
|
+
* Jordan Sissel (jordansissel)
|
6
|
+
* Richard Pijnenburg (electrical)
|
7
|
+
* Lucas Bremgartner (breml)
|
8
|
+
* Pere Urbón (purbon)
|
9
|
+
* Colin Surprenant (colinsurprenant)
|
10
|
+
* Brice Figureau (masterzen)
|
11
|
+
* John E. Vincent (lusis)
|
12
|
+
|
13
|
+
Note: If you've sent us patches, bug reports, or otherwise contributed to
|
14
|
+
Logstash, and you aren't on the list above and want to be, please let us know
|
15
|
+
and we'll make sure you're here. Contributions from folks like you are what make
|
16
|
+
open source awesome.
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Copyright (c) 2012–2015 Elasticsearch <http://www.elastic.co>
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
data/NOTICE.TXT
ADDED
data/README.md
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
# logstash-mixin-zeromq
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/logstash-plugins/logstash-mixin-zeromq.svg?branch=master)](https://travis-ci.org/logstash-plugins/logstash-mixin-zeromq)
|
4
|
+
|
5
|
+
This is a mixin library to share code for zeromq input, output and filter Logstash plugins.
|
6
|
+
|
7
|
+
This code is designed internal use by Logstash plugins.
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'ffi-rzmq'
|
3
|
+
require "logstash/namespace"
|
4
|
+
|
5
|
+
module LogStash::PluginMixins::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::PluginMixins::ZeroMQ
|
@@ -0,0 +1,26 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
|
3
|
+
s.name = 'logstash-mixin-zeromq'
|
4
|
+
s.version = '2.0.0'
|
5
|
+
s.licenses = ['Apache License (2.0)']
|
6
|
+
s.summary = "Mixin to share code for zeromq input, output and filter"
|
7
|
+
s.description = "This gem contains mixin functions, used by 0MQ logstash plugins. This gem is not a stand-alone program"
|
8
|
+
s.authors = ["Elastic"]
|
9
|
+
s.email = 'info@elastic.co'
|
10
|
+
s.homepage = "http://www.elastic.co/guide/en/logstash/current/index.html"
|
11
|
+
s.require_paths = ["lib"]
|
12
|
+
|
13
|
+
# Files
|
14
|
+
s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']
|
15
|
+
|
16
|
+
# Tests
|
17
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
18
|
+
|
19
|
+
# Gem dependencies
|
20
|
+
s.add_runtime_dependency "logstash-core", ">= 2.0.0", "< 3.0.0"
|
21
|
+
|
22
|
+
s.add_runtime_dependency 'ffi-rzmq', '~> 2.0.4'
|
23
|
+
|
24
|
+
s.add_development_dependency 'logstash-devutils'
|
25
|
+
s.add_development_dependency 'logstash-codec-plain'
|
26
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "logstash/devutils/rspec/spec_helper"
|
3
|
+
require 'logstash/plugin_mixins/zeromq'
|
4
|
+
|
5
|
+
class Dummy < LogStash::Inputs::Base
|
6
|
+
attr_accessor :mode
|
7
|
+
|
8
|
+
include LogStash::PluginMixins::ZeroMQ
|
9
|
+
def server?
|
10
|
+
@mode == "server"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe LogStash::PluginMixins::ZeroMQ do
|
15
|
+
let(:basic_config) { {} }
|
16
|
+
let(:impl) {
|
17
|
+
d = Dummy.new(basic_config)
|
18
|
+
d.mode = "server"
|
19
|
+
d
|
20
|
+
}
|
21
|
+
|
22
|
+
it "should initialize with no extra settings" do
|
23
|
+
expect {
|
24
|
+
impl
|
25
|
+
}.not_to raise_error
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should return a ZMQ context" do
|
29
|
+
expect(impl.context).to be_a ZMQ::Context
|
30
|
+
end
|
31
|
+
|
32
|
+
context "when setup" do
|
33
|
+
let(:socket) { context = ZMQ::Context.new; context.socket(ZMQ::REQ) }
|
34
|
+
let(:port) { rand(1000)+1025 }
|
35
|
+
after do
|
36
|
+
socket.close
|
37
|
+
end
|
38
|
+
|
39
|
+
context "a server" do
|
40
|
+
it "should setup a server, bind to address without error" do
|
41
|
+
expect { impl.setup(socket, "tcp://127.0.0.1:#{port}") }.to_not raise_error
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context "a client" do
|
46
|
+
let(:impl_client) {
|
47
|
+
d = Dummy.new(basic_config)
|
48
|
+
d.mode = "client"
|
49
|
+
d
|
50
|
+
}
|
51
|
+
|
52
|
+
it "should setup a client, connecting to address without error" do
|
53
|
+
expect { impl_client.setup(socket, "tcp://127.0.0.1:#{port}") }.to_not raise_error
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context "when error_check" do
|
59
|
+
it "should not raise an error for return code 0 or greater" do
|
60
|
+
expect { impl.error_check(0, "test return values" ) }.to_not raise_error
|
61
|
+
expect { impl.error_check(1, "test return values" ) }.to_not raise_error
|
62
|
+
end
|
63
|
+
it "should raise an error for return code below 0" do
|
64
|
+
expect { impl.error_check(-1, "test return values" ) }.to raise_error
|
65
|
+
expect { impl.error_check(-999, "test return values" ) }.to raise_error
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context "when socketopts" do
|
70
|
+
let(:socket) { context = ZMQ::Context.new; context.socket(ZMQ::REQ) }
|
71
|
+
after do
|
72
|
+
socket.close
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should set SNDHWM to numeric value without error" do
|
76
|
+
expect { impl.setopts(socket, { "ZMQ::SNDHWM" => "50" } ) }.to_not raise_error
|
77
|
+
end
|
78
|
+
it "should raise an error if set SNDHWM to a non numeric value" do
|
79
|
+
expect { impl.setopts(socket, { "ZMQ::SNDHWM" => "foo" } ) }.to raise_error
|
80
|
+
end
|
81
|
+
it "should raise an error for unknown ZMQ option" do
|
82
|
+
expect { impl.setopts(socket, { "ZMQ::UNKNOWNOPT" => "foo" } ) }.to raise_error
|
83
|
+
end
|
84
|
+
it "should set IDENTITY to string value without error" do
|
85
|
+
expect { impl.setopts(socket, { "ZMQ::IDENTITY" => "my_named_queue" } ) }.to_not raise_error
|
86
|
+
end
|
87
|
+
it "should raise an error for a wrong formated ZMQ option" do
|
88
|
+
expect { impl.setopts(socket, { "ZMQ..SNDHWM" => "50" } ) }.to raise_error
|
89
|
+
end
|
90
|
+
it "should set multiple options" do
|
91
|
+
expect { impl.setopts(socket, { "ZMQ::SNDHWM" => "50", "ZMQ::SNDBUF" => "50" } ) }.to_not raise_error
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
end
|
metadata
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: logstash-mixin-zeromq
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Elastic
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-04-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - ">="
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: 2.0.0
|
19
|
+
- - "<"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.0.0
|
22
|
+
name: logstash-core
|
23
|
+
prerelease: false
|
24
|
+
type: :runtime
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 2.0.0
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 3.0.0
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - "~>"
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: 2.0.4
|
39
|
+
name: ffi-rzmq
|
40
|
+
prerelease: false
|
41
|
+
type: :runtime
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 2.0.4
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
name: logstash-devutils
|
54
|
+
prerelease: false
|
55
|
+
type: :development
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
requirement: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
name: logstash-codec-plain
|
68
|
+
prerelease: false
|
69
|
+
type: :development
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
description: This gem contains mixin functions, used by 0MQ logstash plugins. This gem is not a stand-alone program
|
76
|
+
email: info@elastic.co
|
77
|
+
executables: []
|
78
|
+
extensions: []
|
79
|
+
extra_rdoc_files: []
|
80
|
+
files:
|
81
|
+
- CHANGELOG.md
|
82
|
+
- CONTRIBUTORS
|
83
|
+
- Gemfile
|
84
|
+
- LICENSE
|
85
|
+
- NOTICE.TXT
|
86
|
+
- README.md
|
87
|
+
- lib/logstash/plugin_mixins/zeromq.rb
|
88
|
+
- logstash-util-zeromq.gemspec
|
89
|
+
- spec/plugin_mixins/zeromq_spec.rb
|
90
|
+
homepage: http://www.elastic.co/guide/en/logstash/current/index.html
|
91
|
+
licenses:
|
92
|
+
- Apache License (2.0)
|
93
|
+
metadata: {}
|
94
|
+
post_install_message:
|
95
|
+
rdoc_options: []
|
96
|
+
require_paths:
|
97
|
+
- lib
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
requirements: []
|
109
|
+
rubyforge_project:
|
110
|
+
rubygems_version: 2.4.8
|
111
|
+
signing_key:
|
112
|
+
specification_version: 4
|
113
|
+
summary: Mixin to share code for zeromq input, output and filter
|
114
|
+
test_files:
|
115
|
+
- spec/plugin_mixins/zeromq_spec.rb
|