rabbitcage 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -46,6 +46,22 @@ RabbitCage works as a transparent, content aware proxy between the connecting cl
46
46
  default :deny
47
47
  end
48
48
 
49
+ ## Performance
50
+ Here are some basic performance measurements which compares a raw connection to RabbitMQ with a filtered one. Check the [spec/performance/test.rb](http://github.com/dsander/rabbitcage/blob/master/spec/performance/test.rb) script to get information about how the tests were run. If you have a more benchmark results or suggestions about how to change the benchmark, please let me know.
51
+
52
+ Average message delay:
53
+ RabbitMQ : 0.00293165922164917
54
+ RabbitCache : 0.00457870006561279
55
+
56
+ For a 1kb message do 1000 times:
57
+ RabbitMQ push to queue : 0.443398952484131
58
+ RabbitMQ pop from queue: 0.711700439453125
59
+ RabbitMQ async get : 0.847184419631958
60
+ RabbitCache push to queue : 0.764634847640991
61
+ RabbitCache pop from queue: 1.02018523216248
62
+ RabbitCache async get : 0.852582693099976
63
+
64
+
49
65
  ## Note on Patches/Pull Requests
50
66
 
51
67
  * Fork the project.
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ begin
6
6
  Jeweler::Tasks.new do |gem|
7
7
  gem.name = "rabbitcage"
8
8
  gem.summary = %Q{A AMQP firewall which allows to restrict user access to RabbitMQ using ACLs.}
9
- gem.description = %Q{RabbitMQ's access control capabilities are rather limited. RabbitCage enables fine-grated permission setups, you define which user can perform which AMQP method on which class.}
9
+ gem.description = %Q{RabbitMQ's access control capabilities are rather limited. RabbitCage enables fine-grained permission setups, you define which user can perform which AMQP method on which class.}
10
10
  gem.email = "git@dsander.de"
11
11
  gem.homepage = "http://github.com/dsander/rabbitcage"
12
12
  gem.authors = ["Dominik Sander"]
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
data/bin/rabbitcage CHANGED
@@ -52,8 +52,15 @@ EOF
52
52
 
53
53
  opts.parse!
54
54
 
55
+
56
+ if !options[:config]
57
+ puts "You need to specify a config file.\n\n"
58
+ puts opts
59
+ exit
60
+ end
55
61
  load(options[:config])
56
62
  name = options[:config].split('/').last.chomp('.rb')
63
+
57
64
  RabbitCage.run('config', options[:host], options[:port], options[:remote_host], options[:remote_port], options[:log_level])
58
65
  rescue Exception => e
59
66
  if e.instance_of?(SystemExit)
@@ -11,6 +11,7 @@ class RabbitCage
11
11
  LOGGER.info "Accepted #{peer}"
12
12
  @buffer = []
13
13
  @tries = 0
14
+ @user = 'guest'
14
15
  RabbitCage.incr
15
16
  end
16
17
 
@@ -35,7 +36,7 @@ class RabbitCage
35
36
  data2 = data.dup
36
37
 
37
38
  while frame = AMQP::Frame.parse(data2)
38
- LOGGER.debug "Got frame: " + frame.payload.inspect
39
+ LOGGER.debug "Got frame: " + frame.inspect
39
40
  case frame.payload
40
41
  when AMQP::Protocol::Connection::Open
41
42
  @vhost = frame.payload.virtual_host
@@ -67,10 +67,13 @@ class RabbitCage
67
67
  require 'erb'
68
68
  method = ERB.new(%q[
69
69
  def filter(frame)
70
+ <%- @rules[:any].each do |rule| -%>
71
+ return :<%= rule[:permission] %> if <%= rule[:properties] %>
72
+ <%- end -%>
73
+ <%- @rules.delete(:any) -%>
74
+ return :allow if (frame.class == AMQP::Protocol::Header || frame.class == String)
70
75
  <%- if @rules.any? -%>
71
- <%- @rules[:any].each do |rule| -%>
72
- return :<%= rule[:permission] %> if <%= rule[:properties] %>
73
- <%- end -%>
76
+
74
77
  case frame # 4
75
78
  <%- @rules.each_pair do |klass, r|-%>
76
79
  <%- next if klass == :any -%>
@@ -0,0 +1,96 @@
1
+ require 'amqp'
2
+ require 'mq'
3
+ require 'eventmachine'
4
+ require 'benchmark'
5
+ require 'bunny'
6
+
7
+ # Config file used
8
+ #include RabbitCageACL
9
+ #require 'pp'
10
+ #config do
11
+ # allow 'admin', :all, :all
12
+ # allow 'guest', :all, :queue, :name => /^(?!reserved_)/
13
+ # allow 'guest', :all, :exchange, :name => /^(?!private_)/
14
+ # allow 'guest', [:publish, :consume, :get], :basic
15
+ # allow 'guest', :all, :connection
16
+ # allow 'guest', :all, :channel
17
+ # allow 'guest', :all, :access
18
+ # default :deny
19
+ #end
20
+
21
+
22
+ def messure_delay
23
+ delay = []
24
+ i = 0
25
+
26
+ amq = MQ.new
27
+ amq.queue('delay', :exclusive=>true, :auto_delete=>true).bind(amq.fanout('performance_test')).subscribe do |msg|
28
+ delay << Time.now.to_f-msg.to_f
29
+ if i == 100
30
+ @timer.cancel
31
+ puts delay.reduce(:+)/delay.length
32
+ AMQP.stop{EM.stop}
33
+ end
34
+ end
35
+
36
+ @timer = EventMachine::add_periodic_timer(0.01) do
37
+ i += 1
38
+ amq.fanout('performance_test').publish(Time.now.to_f)
39
+ end
40
+ end
41
+
42
+ puts "Average message delay:"
43
+ AMQP.start(:port => 5673) do
44
+ print 'RabbitMQ : '
45
+ messure_delay
46
+ end
47
+ AMQP.start(:port => 5672) do
48
+ print 'RabbitCache : '
49
+ messure_delay
50
+ end
51
+
52
+
53
+ def messure_publish_time port, data, message
54
+ b = Bunny.new(:host => 'localhost', :port => port)
55
+ b.start
56
+
57
+ q = b.queue('performance_test')
58
+
59
+ res = Benchmark.realtime do
60
+ 1000.times do
61
+ q.publish(@data)
62
+ end
63
+ end
64
+ puts "#{message} push to queue : #{res}"
65
+ res = Benchmark.realtime do
66
+ 1000.times do
67
+ q.pop
68
+ end
69
+ end
70
+ puts "#{message} pop from queue: #{res}"
71
+
72
+ 1000.times do
73
+ q.publish(@data)
74
+ end
75
+ b.stop
76
+ i = 1
77
+
78
+ res = Benchmark.realtime do
79
+ AMQP.start(:port => port) do
80
+ amq = MQ.new
81
+ amq.queue('performance_test', :exclusive=>true, :auto_delete=>true).bind(amq.fanout('performance_test')).subscribe do |msg|
82
+ i += 1
83
+ if i == 1000
84
+ AMQP.stop{EM.stop}
85
+ end
86
+ end
87
+ end
88
+ end
89
+ puts "#{message} async get : #{res}"
90
+ end
91
+
92
+ @data = "x"*1024
93
+ puts "For a 1kb message do 1000 times:"
94
+ messure_publish_time 5673, @data, 'RabbitMQ '
95
+ messure_publish_time 5672, @data, 'RabbitCache'
96
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rabbitcage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dominik Sander
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-20 00:00:00 +01:00
12
+ date: 2009-12-21 00:00:00 +01:00
13
13
  default_executable: rabbitcage
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -42,7 +42,7 @@ dependencies:
42
42
  - !ruby/object:Gem::Version
43
43
  version: 0.12.10
44
44
  version:
45
- description: RabbitMQ's access control capabilities are rather limited. RabbitCage enables fine-grated permission setups, you define which user can perform which AMQP method on which class.
45
+ description: RabbitMQ's access control capabilities are rather limited. RabbitCage enables fine-grained permission setups, you define which user can perform which AMQP method on which class.
46
46
  email: git@dsander.de
47
47
  executables:
48
48
  - rabbitcage
@@ -64,6 +64,7 @@ files:
64
64
  - lib/rabbitcage/core_extensions.rb
65
65
  - lib/rabbitcage/filter.rb
66
66
  - lib/rabbitcage/server_connection.rb
67
+ - spec/performance/test.rb
67
68
  - spec/rabbitcage_spec.rb
68
69
  - spec/spec_helper.rb
69
70
  has_rdoc: true
@@ -97,3 +98,4 @@ summary: A AMQP firewall which allows to restrict user access to RabbitMQ using
97
98
  test_files:
98
99
  - spec/rabbitcage_spec.rb
99
100
  - spec/spec_helper.rb
101
+ - spec/performance/test.rb