cottontail 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/cottontail.gemspec CHANGED
@@ -18,7 +18,5 @@ Gem::Specification.new do |s|
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  s.require_paths = ["lib"]
20
20
 
21
- # specify any dependencies here; for example:
22
- # s.add_development_dependency "rspec"
23
21
  s.add_runtime_dependency "bunny"
24
22
  end
data/lib/cottontail.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'logger'
2
+ require 'bunny'
2
3
 
3
4
  module Cottontail
4
5
  class RouteNotFound < StandardError; end
@@ -45,6 +46,21 @@ module Cottontail
45
46
 
46
47
  @errors = {}
47
48
  @routes = {}
49
+
50
+ # default logger
51
+ set(:logger) { Logger.new(STDOUT) }
52
+
53
+ # retry settings
54
+ set(:retries) { true }
55
+ set(:delay_on_retry) { 2 }
56
+
57
+ # default subscribe loop
58
+ set :subscribe, {}, proc { |m| route! m }
59
+
60
+ # default bunny options
61
+ set :client, {}
62
+ set :exchange, "default", :type => :topic
63
+ set :queue, "default"
48
64
  end
49
65
 
50
66
  # Set runtime configuration
@@ -142,10 +158,10 @@ module Cottontail
142
158
 
143
159
  # Starts the consumer service and enters the subscribe loop.
144
160
  def run
145
- logger.debug "[Cottontial] Declaring exchange"
161
+ logger.debug "[Cottontail] Declaring exchange"
146
162
  exchange = client.exchange( *settings(:exchange) )
147
163
 
148
- logger.debug "[Cottontial] Declaring queue"
164
+ logger.debug "[Cottontail] Declaring queue"
149
165
  queue = client.queue( *settings(:queue) )
150
166
 
151
167
  routes.keys.each do |key|
@@ -164,6 +180,7 @@ module Cottontail
164
180
  # raise when no retries are defined
165
181
  raise( e, caller ) unless settings(:retries)
166
182
 
183
+ logger.debug "[Cottontail] Going to retry in #{settings(:delay_on_retry)} seconds..."
167
184
  sleep settings(:delay_on_retry) if settings(:delay_on_retry)
168
185
  retry
169
186
  end
@@ -244,21 +261,6 @@ module Cottontail
244
261
  # === Perform the initial setup
245
262
  reset!
246
263
 
247
- # default subscribe loop
248
- set :subscribe, [{}, proc { |m| route! m }]
249
-
250
- # default logger
251
- set :logger, Logger.new(STDOUT)
252
-
253
- # retry settings
254
- set :retries, true
255
- set :delay_on_retry, 2
256
-
257
- # default bunny options
258
- set :client, {}
259
- set :exchange, "default", :type => :topic
260
- set :queue, "default"
261
-
262
264
  end
263
265
  end
264
266
 
@@ -1,3 +1,3 @@
1
1
  module Cottontail
2
- VERSION = "0.0.2"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: cottontail
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.2
5
+ version: 0.1.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Rudolf Schmidt
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-02-02 00:00:00 Z
13
+ date: 2012-02-16 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bunny