frenzy_bunnies 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,13 +1,16 @@
1
1
  require 'logger'
2
2
 
3
3
  class FrenzyBunnies::Context
4
- attr_reader :queue_factory, :logger
4
+ attr_reader :queue_factory, :logger, :env
5
5
 
6
6
  def initialize(opts={})
7
7
  @opts = opts
8
8
  @opts[:host] ||= 'localhost'
9
9
  @opts[:exchange] ||= 'frenzy_bunnies'
10
10
  @opts[:heartbeat] ||= 5
11
+ @opts[:env] ||= ''
12
+
13
+ @env = @opts[:env]
11
14
  @logger = @opts[:logger] || Logger.new(STDOUT)
12
15
  @connection = HotBunnies.connect(:host => @opts[:host], :heartbeat_interval => @opts[:heartbeat])
13
16
  @connection.add_shutdown_listener(lambda { |cause| @logger.error("Disconnected: #{cause}"); stop;})
@@ -1,3 +1,3 @@
1
1
  module FrenzyBunnies
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -21,6 +21,8 @@ module FrenzyBunnies::Worker
21
21
  def start(context)
22
22
  @logger = context.logger
23
23
 
24
+ queue_name = "#{@queue_name}#{context.env}"
25
+
24
26
  @queue_opts[:prefetch] ||= 10
25
27
  @queue_opts[:durable] ||= false
26
28
 
@@ -30,10 +32,10 @@ module FrenzyBunnies::Worker
30
32
  @thread_pool = Executors.new_cached_thread_pool
31
33
  end
32
34
 
33
- q = context.queue_factory.build_queue(@queue_name, @queue_opts[:prefetch], @queue_opts[:durable])
35
+ q = context.queue_factory.build_queue(queue_name, @queue_opts[:prefetch], @queue_opts[:durable])
34
36
  @s = q.subscribe(:ack => true)
35
37
 
36
- say "#{@queue_opts[:threads] ? "#{@queue_opts[:threads]} threads " : ''}with #{@queue_opts[:prefetch]} prefetch on <#{@queue_name}>."
38
+ say "#{@queue_opts[:threads] ? "#{@queue_opts[:threads]} threads " : ''}with #{@queue_opts[:prefetch]} prefetch on <#{queue_name}>."
37
39
 
38
40
  @s.each(:blocking => false, :executor => @thread_pool) do |h, msg|
39
41
  wkr = new
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: frenzy_bunnies
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-24 00:00:00.000000000 Z
12
+ date: 2012-07-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: hot_bunnies