ramon 0.4.2 → 0.4.3
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.
- data/Gemfile +1 -2
- data/benchmarks.rb +80 -28
- data/lib/ramon.rb +1 -0
- data/lib/ramon/sender.rb +5 -14
- data/lib/ramon/version.rb +1 -1
- data/lib/ramon/zeromq.rb +24 -0
- metadata +7 -8
data/Gemfile
CHANGED
data/benchmarks.rb
CHANGED
@@ -1,39 +1,91 @@
|
|
1
1
|
require "rubygems"
|
2
|
+
require "bundler/setup"
|
2
3
|
require "ramon"
|
3
4
|
require "logger"
|
5
|
+
require 'singleton'
|
6
|
+
require "zmq"
|
4
7
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
+
runs = 10000
|
9
|
+
http_address = 'http://127.0.0.1:2464'
|
10
|
+
http_bench = false
|
11
|
+
zeromq_bench = true
|
12
|
+
standart_bench = true
|
13
|
+
|
14
|
+
puts "Runs: #{runs}"
|
15
|
+
|
16
|
+
if http_bench == true
|
17
|
+
Ramon.configure do |config|
|
18
|
+
config.address = http_address
|
19
|
+
config.logger = Logger.new("/dev/null")
|
20
|
+
end
|
21
|
+
|
22
|
+
start_time = Time.now
|
23
|
+
(1..runs).each {
|
24
|
+
Ramon.log('test')
|
25
|
+
}
|
26
|
+
end_time = Time.now
|
27
|
+
puts "HTTP logging #{(end_time - start_time)} seconds"
|
8
28
|
end
|
9
29
|
|
10
|
-
start_time = Time.now
|
11
|
-
(1..1000).each {
|
12
|
-
Ramon.log('test')
|
13
|
-
}
|
14
|
-
end_time = Time.now
|
15
|
-
puts "HTTP logging #{(end_time - start_time)} seconds"
|
16
30
|
|
31
|
+
if zeromq_bench == true
|
32
|
+
|
33
|
+
class ZeroMQ
|
34
|
+
include Singleton
|
35
|
+
|
36
|
+
@@address = ""
|
37
|
+
def self.address= address
|
38
|
+
@@address = address
|
39
|
+
end
|
40
|
+
|
41
|
+
def initialize
|
42
|
+
@context = ZMQ::Context.new(1)
|
43
|
+
@socket = @context.socket(ZMQ::DEALER)
|
44
|
+
@socket.connect("tcp://#{@@address}")
|
45
|
+
@socket.setsockopt(ZMQ::LINGER, 0)
|
46
|
+
@socket.setsockopt(ZMQ::SWAP, 25000000) # 25MB disk swap
|
47
|
+
end
|
48
|
+
|
49
|
+
def post(data)
|
50
|
+
@socket.send(data, ZMQ::NOBLOCK)
|
51
|
+
end
|
17
52
|
|
18
|
-
Ramon.configure do |config|
|
19
|
-
config.address = '127.0.0.1:5464'
|
20
|
-
config.protocol = 'zeromq'
|
21
|
-
config.logger = Logger.new("/dev/null")
|
22
53
|
end
|
23
54
|
|
24
|
-
start_time = Time.now
|
25
|
-
(1..
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
55
|
+
#start_time = Time.now
|
56
|
+
#(1..runs).each {
|
57
|
+
#json_data = {:type => 'log', :content => {:message => 'zeromq test'}}
|
58
|
+
#json_data = json_data.to_json
|
59
|
+
#ZeroMQ.address = '127.0.0.1:5464'
|
60
|
+
#ZeroMQ.instance.post(json_data)
|
61
|
+
#}
|
62
|
+
#end_time = Time.now
|
63
|
+
#puts "ZeroMQ logging #{(end_time - start_time)} seconds"
|
64
|
+
|
65
|
+
Ramon.configure do |config|
|
66
|
+
config.address = '127.0.0.1:5464'
|
67
|
+
config.protocol = 'zeromq'
|
68
|
+
config.logger = Logger.new(STDOUT)
|
69
|
+
end
|
70
|
+
|
71
|
+
start_time = Time.now
|
72
|
+
(1..runs).each {
|
73
|
+
Ramon.log('ramon zeromq test')
|
74
|
+
}
|
75
|
+
end_time = Time.now
|
76
|
+
puts "Ramon ZeroMQ logging #{(end_time - start_time)} seconds"
|
77
|
+
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
if standart_bench == true
|
83
|
+
log = Logger.new('bench.log')
|
84
|
+
start_time = Time.now
|
85
|
+
(1..runs).each {
|
86
|
+
log.info('test')
|
87
|
+
}
|
88
|
+
end_time = Time.now
|
89
|
+
puts "Standard logging #{(end_time - start_time)} seconds"
|
90
|
+
end
|
39
91
|
|
data/lib/ramon.rb
CHANGED
data/lib/ramon/sender.rb
CHANGED
@@ -1,10 +1,6 @@
|
|
1
1
|
require 'net/http'
|
2
2
|
require 'json'
|
3
3
|
require 'zlib'
|
4
|
-
begin
|
5
|
-
require 'zmq'
|
6
|
-
rescue LoadError
|
7
|
-
end
|
8
4
|
|
9
5
|
module Ramon
|
10
6
|
class Sender
|
@@ -65,22 +61,17 @@ module Ramon
|
|
65
61
|
|
66
62
|
def post_zeromq(type, data = {})
|
67
63
|
if defined?(ZMQ)
|
68
|
-
|
69
|
-
socket = context.socket(ZMQ::DEALER)
|
70
|
-
socket.connect("tcp://#{address}")
|
71
|
-
socket.setsockopt(ZMQ::LINGER,0)
|
72
|
-
json_data = {:type => type,
|
73
|
-
:content => data}
|
64
|
+
json_data = {:type => type, :content => data}
|
74
65
|
if app_key
|
75
66
|
json_data['app_key'] = app_key
|
76
67
|
end
|
77
68
|
|
78
69
|
json_data = json_data.to_json
|
79
70
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
71
|
+
ZeroMQ.address = address
|
72
|
+
ZeroMQ.instance.post(json_data)
|
73
|
+
else
|
74
|
+
puts "ZeroMQ is not installed. You can install it with `gem install zmq`"
|
84
75
|
end
|
85
76
|
end
|
86
77
|
|
data/lib/ramon/version.rb
CHANGED
data/lib/ramon/zeromq.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
module Ramon
|
3
|
+
class ZeroMQ
|
4
|
+
include Singleton
|
5
|
+
@@address = ""
|
6
|
+
def self.address= address
|
7
|
+
@@address = address
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
context = ZMQ::Context.new(1)
|
12
|
+
@socket = context.socket(ZMQ::DEALER)
|
13
|
+
@socket.connect("tcp://#{@@address}")
|
14
|
+
@socket.setsockopt(ZMQ::LINGER, 0)
|
15
|
+
@socket.setsockopt(ZMQ::SWAP, 25000000) # 25MB disk swap
|
16
|
+
end
|
17
|
+
|
18
|
+
def post(data)
|
19
|
+
@socket.send(data, ZMQ::NOBLOCK)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ramon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 9
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.4.
|
9
|
+
- 3
|
10
|
+
version: 0.4.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- martinrusev
|
@@ -15,8 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-04-
|
19
|
-
default_executable:
|
18
|
+
date: 2012-04-27 00:00:00 Z
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
21
|
name: json
|
@@ -56,6 +55,7 @@ files:
|
|
56
55
|
- lib/ramon/railtie.rb
|
57
56
|
- lib/ramon/sender.rb
|
58
57
|
- lib/ramon/version.rb
|
58
|
+
- lib/ramon/zeromq.rb
|
59
59
|
- ramon.gemspec
|
60
60
|
- spec/config_spec.rb
|
61
61
|
- spec/exception_data_spec.rb
|
@@ -64,7 +64,6 @@ files:
|
|
64
64
|
- spec/spec_helper.rb
|
65
65
|
- spec/web_spec.rb
|
66
66
|
- spec/zeromq_spec.rb
|
67
|
-
has_rdoc: true
|
68
67
|
homepage: http://amon.cx
|
69
68
|
licenses: []
|
70
69
|
|
@@ -94,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
93
|
requirements: []
|
95
94
|
|
96
95
|
rubyforge_project: ramon
|
97
|
-
rubygems_version: 1.
|
96
|
+
rubygems_version: 1.8.15
|
98
97
|
signing_key:
|
99
98
|
specification_version: 3
|
100
99
|
summary: Ruby binding for Amon
|