bunnicula 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/bunnicula.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{bunnicula}
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Nathan Stults"]
@@ -30,6 +30,7 @@ Gem::Specification.new do |s|
30
30
  "config/environments/development.rb",
31
31
  "config/environments/production.rb",
32
32
  "config/environments/test.rb",
33
+ "config/post-daemonize/configure_bunnicula.rb",
33
34
  "config/post-daemonize/readme",
34
35
  "config/pre-daemonize/bunnicula.rb",
35
36
  "config/pre-daemonize/readme",
@@ -0,0 +1,32 @@
1
+ if( config = DaemonKit.arguments.options[:configuration_file])
2
+ load config if File.exist?(config)
3
+ end
4
+
5
+ if (source_uri = DaemonKit.arguments.options[:source_uri])
6
+ Bunnicula.victim(source_uri)
7
+ end
8
+
9
+ if (DaemonKit.arguments.options[:targets])
10
+ DaemonKit.logger.debug("Target options from commandline:#{DaemonKit.arguments.options[:targets].inspect}")
11
+ targets = DaemonKit.arguments.options[:targets]
12
+ targets.each do |target_config|
13
+ Bunnicula.transfusion_to(target_config[:target_uri]) do |vamp|
14
+ target_config[:relays].each do |relay_config|
15
+ vamp.relay do |r|
16
+ from_options = {}
17
+ from_options[:durable] = relay_config[:from_durable] if relay_config[:from_durable]
18
+ from_options[:ack] = relay_config[:from_ack] if relay_config[:from_ack]
19
+ from_options[:type] = relay_config[:from_type] if relay_config[:from_type]
20
+ r.from relay_config[:from], from_options
21
+ if (to_exchange = relay_config[:to])
22
+ to_options = {}
23
+ to_options[:durable] = relay_config[:to_durable] if relay_config[:to_durable]
24
+ to_options[:ack] = relay_config[:to_ack] if relay_config[:to_ack]
25
+ to_options[:type] = relay_config[:to_type] if relay_config[:to_type]
26
+ r.to to_exchange, to_options
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -12,7 +12,7 @@ class Bunnicula::Relay
12
12
  end
13
13
 
14
14
  def to(*args)
15
- return @target_exchange if args.length == 0
15
+ return @target_exchange || @source_exchange if args.length == 0
16
16
  options = args.extract_options!
17
17
  exchange_name = args.pop
18
18
  @target_exchange = Bunnicula::Exchange.new(exchange_name,options)
@@ -1,3 +1,3 @@
1
1
  module Bunnicula
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
@@ -1,63 +1,34 @@
1
- # Generated amqp daemon
2
-
3
- # Do your post daemonization configuration here
4
- # At minimum you need just the first line (without the block), or a lot
5
- # of strange things might start happening...
6
- DaemonKit::Application.running! do |config|
7
- # Trap signals with blocks or procs
8
- # config.trap( 'INT' ) do
9
- # # do something clever
10
- # end
11
- config.trap( 'TERM', Proc.new { Bunnicula::BunnyFarm.stop } )
12
- end
13
-
14
- if( config = DaemonKit.arguments.options[:configuration_file])
15
- load config if File.exist?(config)
16
- end
17
-
18
- if (source_uri = DaemonKit.arguments.options[:source_uri])
19
- Bunnicula.victim(source_uri)
20
- end
21
-
22
- if (DaemonKit.arguments.options[:targets])
23
- targets = DaemonKit.arguments.options[:targets]
24
- targets.each do |target_config|
25
- Bunnicula.transfusion_to(target_config[:target_uri]) do |vamp|
26
- target_config[:relays].each do |relay_config|
27
- vamp.relay do |r|
28
- from_options = {}
29
- from_options[:durable] = relay_config[:from_durable] if relay_config[:from_durable]
30
- from_options[:ack] = relay_config[:from_ack] if relay_config[:from_ack]
31
- from_options[:type] = relay_config[:from_type] if relay_config[:from_type]
32
- r.from relay_config[:from], from_options
33
- if (to_exchange = relay_config[:to])
34
- to_options = {}
35
- to_options[:durable] = relay_config[:to_durable] if relay_config[:to_durable]
36
- to_options[:ack] = relay_config[:to_ack] if relay_config[:to_ack]
37
- to_options[:type] = relay_config[:to_type] if relay_config[:to_type]
38
- r.to to_exchange, to_options
39
- end
40
- end
41
- end
42
- end
43
- end
44
- end
45
-
46
- # Run an event-loop for processing
47
- raise "Bunnicula requires a victim. Please specify a source rabbitmq instance via a configuration file or commandline argument" unless Bunnicula.victim
48
- Bunnicula::AMQP.run(Bunnicula.victim.to_h) do
49
- # Inside this block we're running inside the reactor setup by the
50
- # amqp gem. Any code in the examples (from the gem) would work just
51
- # fine here.
52
-
53
- # Uncomment this for connection keep-alive
54
- # AMQP.conn.connection_status do |status|
55
- # DaemonKit.logger.debug("AMQP connection status changed: #{status}")
56
- # if status == :disconnected
57
- # AMQP.conn.reconnect(true)
58
- # end
59
- # end
60
-
61
- amq = ::MQ.new
62
- Bunnicula.suck(amq)
63
- end
1
+ # Generated amqp daemon
2
+
3
+ # Do your post daemonization configuration here
4
+ # At minimum you need just the first line (without the block), or a lot
5
+ # of strange things might start happening...
6
+ DaemonKit::Application.running! do |config|
7
+ # Trap signals with blocks or procs
8
+ # config.trap( 'INT' ) do
9
+ # # do something clever
10
+ # end
11
+ config.trap( 'TERM', Proc.new { Bunnicula::BunnyFarm.stop } )
12
+ end
13
+
14
+
15
+
16
+
17
+ # Run an event-loop for processing
18
+ raise "Bunnicula requires a victim. Please specify a source rabbitmq instance via a configuration file or commandline argument" unless Bunnicula.victim
19
+ Bunnicula::AMQP.run(Bunnicula.victim.to_h) do
20
+ # Inside this block we're running inside the reactor setup by the
21
+ # amqp gem. Any code in the examples (from the gem) would work just
22
+ # fine here.
23
+
24
+ # Uncomment this for connection keep-alive
25
+ # AMQP.conn.connection_status do |status|
26
+ # DaemonKit.logger.debug("AMQP connection status changed: #{status}")
27
+ # if status == :disconnected
28
+ # AMQP.conn.reconnect(true)
29
+ # end
30
+ # end
31
+
32
+ amq = ::MQ.new
33
+ Bunnicula.suck(amq)
34
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bunnicula
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Nathan Stults
@@ -104,6 +104,7 @@ files:
104
104
  - config/environments/development.rb
105
105
  - config/environments/production.rb
106
106
  - config/environments/test.rb
107
+ - config/post-daemonize/configure_bunnicula.rb
107
108
  - config/post-daemonize/readme
108
109
  - config/pre-daemonize/bunnicula.rb
109
110
  - config/pre-daemonize/readme