logjam_agent 0.19.1 → 0.19.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -2
- data/Rakefile +14 -1
- data/lib/logjam_agent/util.rb +7 -0
- data/lib/logjam_agent/version.rb +1 -1
- data/lib/logjam_agent/zmq_forwarder.rb +11 -8
- data/logjam_agent.gemspec +1 -0
- data/test/test_helper.rb +11 -0
- data/test/util_test.rb +28 -0
- data/test/zmq_forwarder_test.rb +17 -0
- metadata +23 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e9d6b9f04d490d4972525d48260a3615ac025f7
|
4
|
+
data.tar.gz: 57eb3ff05b85e938cbc311bb3129f04ac917e2c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 171dbc3e7dcee9784ad8ce9a24b2bc09c879f96c5e7703dc415ea5be771a5ea88afdcee5098ed323331a8d15028f7287a428983cb3e610f1ba873b31bc1dec11
|
7
|
+
data.tar.gz: 379fb53d4e360366f5b9e43994c0519b76b680db11099eebdfa9bd208d200316f32167b9741fa5bf83cadf3af48cc33740612f99b1ba412f293521004359e0a8
|
data/README.md
CHANGED
@@ -38,8 +38,14 @@ module LogjamAgent
|
|
38
38
|
# Configure the application revision (optional). Defaults to (git rev-parse HEAD).
|
39
39
|
# self.application_revision = "f494e11afa0738b279517a2a96101a952052da5d"
|
40
40
|
|
41
|
-
# Configure request data forwarder for ZeroMQ.
|
42
|
-
|
41
|
+
# Configure request data forwarder for ZeroMQ. Default options as given below.
|
42
|
+
# the host parameter can be a comma separted list of zmq connection specifictions,
|
43
|
+
# where ths protocol prefix and port suffix are optional.
|
44
|
+
add_forwarder(:zmq,
|
45
|
+
:host => "localhost",
|
46
|
+
:port => 9605,
|
47
|
+
:linger => 100,
|
48
|
+
:snd_hwm => 100)
|
43
49
|
|
44
50
|
# Configure request data forwarder for AMQP.
|
45
51
|
# add_forwarder(:amqp, :host => "message.broker.at.your.org")
|
data/Rakefile
CHANGED
@@ -1 +1,14 @@
|
|
1
|
-
require
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/testtask'
|
4
|
+
require 'bundler/gem_tasks'
|
5
|
+
|
6
|
+
Rake::TestTask.new do |t|
|
7
|
+
t.libs << "test"
|
8
|
+
t.test_files = FileList['test/**/*_test.rb']
|
9
|
+
t.verbose = true
|
10
|
+
end
|
11
|
+
|
12
|
+
task :default do
|
13
|
+
Rake::Task[:test].invoke
|
14
|
+
end
|
data/lib/logjam_agent/util.rb
CHANGED
@@ -57,5 +57,12 @@ module LogjamAgent
|
|
57
57
|
sequence = unpack_uint64_big_endian(info[16..23])
|
58
58
|
[tag, compression_method, version, device, sent, sequence]
|
59
59
|
end
|
60
|
+
|
61
|
+
def augment_connection_spec(spec, default_port)
|
62
|
+
protocol, host, port = %r{\A(?:([^:]+)://)?([^:]+)(?::(\d+))?\z}.match(spec).captures
|
63
|
+
protocol ||= "tcp"
|
64
|
+
port ||= default_port
|
65
|
+
"#{protocol}://#{host}:#{port}"
|
66
|
+
end
|
60
67
|
end
|
61
68
|
end
|
data/lib/logjam_agent/version.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module LogjamAgent
|
2
2
|
class ZMQForwarder
|
3
|
-
attr_reader :app, :env
|
3
|
+
attr_reader :app, :env, :connection_specs
|
4
4
|
|
5
5
|
include Util
|
6
6
|
|
@@ -10,15 +10,18 @@ module LogjamAgent
|
|
10
10
|
@env = args[1] || LogjamAgent.environment_name
|
11
11
|
@app_env = "#{@app}-#{@env}"
|
12
12
|
@config = default_options.merge!(opts)
|
13
|
-
@
|
14
|
-
|
13
|
+
@connection_specs = @config[:host].split(',').map do |host|
|
14
|
+
augment_connection_spec(host, @config[:port])
|
15
|
+
end
|
15
16
|
@sequence = 0
|
16
17
|
end
|
17
18
|
|
18
19
|
def default_options
|
19
20
|
{
|
20
21
|
:host => "localhost",
|
21
|
-
:port =>
|
22
|
+
:port => 9605,
|
23
|
+
:linger => 100,
|
24
|
+
:snd_hwm => 100,
|
22
25
|
}
|
23
26
|
end
|
24
27
|
|
@@ -41,10 +44,10 @@ module LogjamAgent
|
|
41
44
|
@socket ||=
|
42
45
|
begin
|
43
46
|
socket = self.class.context.socket(ZMQ::PUSH)
|
44
|
-
socket.setsockopt(ZMQ::LINGER,
|
45
|
-
socket.setsockopt(ZMQ::SNDHWM,
|
46
|
-
@
|
47
|
-
socket.connect(
|
47
|
+
socket.setsockopt(ZMQ::LINGER, @config[:linger])
|
48
|
+
socket.setsockopt(ZMQ::SNDHWM, @config[:snd_hwm])
|
49
|
+
@connection_specs.each do |spec|
|
50
|
+
socket.connect(spec)
|
48
51
|
end
|
49
52
|
at_exit { reset }
|
50
53
|
socket
|
data/logjam_agent.gemspec
CHANGED
@@ -23,6 +23,7 @@ Gem::Specification.new do |s|
|
|
23
23
|
s.add_development_dependency "snappy"
|
24
24
|
s.add_development_dependency "oj"
|
25
25
|
s.add_development_dependency "byebug"
|
26
|
+
s.add_development_dependency "minitest"
|
26
27
|
|
27
28
|
s.add_runtime_dependency "activesupport"
|
28
29
|
s.add_runtime_dependency "time_bandits", [">= 0.6.0"]
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'minitest/unit'
|
3
|
+
require 'minitest/pride' if ENV['RAINBOW_COLORED_TESTS'] == "1" && $stdout.tty?
|
4
|
+
# require 'mocha/setup'
|
5
|
+
|
6
|
+
require_relative "../lib/logjam_agent"
|
7
|
+
|
8
|
+
class MiniTest::Test
|
9
|
+
require "active_support/testing/declarative"
|
10
|
+
extend ActiveSupport::Testing::Declarative
|
11
|
+
end
|
data/test/util_test.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require_relative "test_helper.rb"
|
2
|
+
|
3
|
+
module LogjamAgent
|
4
|
+
class UtilTest < MiniTest::Test
|
5
|
+
include LogjamAgent::Util
|
6
|
+
|
7
|
+
test "does not change a full spec" do
|
8
|
+
augmented = augment_connection_spec("tcp://a:1", 2)
|
9
|
+
assert_equal "tcp://a:1", augmented
|
10
|
+
end
|
11
|
+
|
12
|
+
test "adds default port when missing" do
|
13
|
+
augmented = augment_connection_spec("tcp://a", 1)
|
14
|
+
assert_equal "tcp://a:1", augmented
|
15
|
+
end
|
16
|
+
|
17
|
+
test "adds default protocol when missing" do
|
18
|
+
augmented = augment_connection_spec("a:1", 2)
|
19
|
+
assert_equal "tcp://a:1", augmented
|
20
|
+
end
|
21
|
+
|
22
|
+
test "adds default protocol and default port when missing" do
|
23
|
+
augmented = augment_connection_spec("a", 1)
|
24
|
+
assert_equal "tcp://a:1", augmented
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require_relative "test_helper.rb"
|
2
|
+
|
3
|
+
module LogjamAgent
|
4
|
+
class ZMQForwarderTest < MiniTest::Test
|
5
|
+
|
6
|
+
test "sets up single connection with default port" do
|
7
|
+
f = ZMQForwarder.new(:host => "a.b.c", :port => 3001)
|
8
|
+
assert_equal ["tcp://a.b.c:3001"], f.connection_specs
|
9
|
+
end
|
10
|
+
|
11
|
+
test "sets up multiple connections" do
|
12
|
+
f = ZMQForwarder.new(:host => "a.b.c,tcp://x.y.z:9000,zmq.gnu.org:600")
|
13
|
+
assert_equal %w(tcp://a.b.c:9605 tcp://x.y.z:9000 tcp://zmq.gnu.org:600), f.connection_specs
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logjam_agent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.19.
|
4
|
+
version: 0.19.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Kaes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: minitest
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: activesupport
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -134,6 +148,9 @@ files:
|
|
134
148
|
- lib/logjam_agent/zmq_forwarder.rb
|
135
149
|
- logjam_agent.gemspec
|
136
150
|
- script/console
|
151
|
+
- test/test_helper.rb
|
152
|
+
- test/util_test.rb
|
153
|
+
- test/zmq_forwarder_test.rb
|
137
154
|
homepage: ''
|
138
155
|
licenses: []
|
139
156
|
metadata: {}
|
@@ -157,4 +174,7 @@ rubygems_version: 2.4.8
|
|
157
174
|
signing_key:
|
158
175
|
specification_version: 4
|
159
176
|
summary: Logjam client library to be used with logjam
|
160
|
-
test_files:
|
177
|
+
test_files:
|
178
|
+
- test/test_helper.rb
|
179
|
+
- test/util_test.rb
|
180
|
+
- test/zmq_forwarder_test.rb
|