ayl-beanstalk 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "ayl-beanstalk"
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["j0hnds@gmail.com"]
12
- s.date = "2011-11-26"
12
+ s.date = "2012-03-06"
13
13
  s.description = "Ayl extension to provide beanstalk support."
14
14
  s.email = "j0hnds@gmail.com"
15
15
  s.executables = ["ayl_beanstalk", "ayl_worker", "ayl_worker_control"]
data/bin/ayl_worker CHANGED
@@ -19,7 +19,8 @@ end
19
19
 
20
20
  require File.join(options[:app_path], options[:app_require])
21
21
 
22
- Ayl::MessageOptions.default_queue_name = options[:tube]
22
+ # Don't set the default queue name if it has already been set else where
23
+ Ayl::MessageOptions.default_queue_name = options[:tube] if Ayl::MessageOptions.default_queue_name == 'default'
23
24
 
24
25
  worker = Ayl::Engine.get_active_engine.worker
25
26
  worker.eval_binding = binding
@@ -13,7 +13,7 @@ module Ayl
13
13
  end
14
14
 
15
15
  def process_messages
16
- logger.info "#{self.class.name} entering process_messages loop"
16
+ logger.info "#{self.class.name} entering process_messages loop watching: #{Ayl::MessageOptions.default_queue_name}"
17
17
  # trap('TERM') { puts "## Got the term signal"; @stop = true }
18
18
  # trap('INT') { puts "## Got the int signal"; @stop = true }
19
19
  # Set the queue that we will be watching
@@ -30,9 +30,12 @@ module Ayl
30
30
  job.delete
31
31
  rescue Exception => ex
32
32
  logger.error "#{self.class.name} Exception in process_messages: #{ex}\n#{ex.backtrace.join("\n")}"
33
+ logger.info "Age of job: #{job.age}"
33
34
  if job.age > 60
35
+ logger.info "Deleting job"
34
36
  job.delete
35
37
  else
38
+ logger.info "Decaying job"
36
39
  job.decay
37
40
  end
38
41
  end
data/spec/worker_spec.rb CHANGED
@@ -12,15 +12,17 @@ describe Ayl::Beanstalk::Worker do
12
12
  @worker = Ayl::Beanstalk::Worker.new
13
13
  @worker.stub_chain(:logger, :info)
14
14
  @worker.stub_chain(:logger, :error)
15
+ Ayl::MessageOptions.default_queue_name = 'default'
15
16
  end
16
17
 
17
18
  it "should wait for a message to be received from beanstalk and process it" do
19
+ Ayl::MessageOptions.default_queue_name = 'the_queue_name'
18
20
  mock_job = mock("Beanstalk::Job")
19
21
  mock_job.should_receive(:delete)
20
22
  mock_job.should_receive(:ybody).and_return({ :type => :ayl, :code => "23.to_s(2)" })
21
23
 
22
24
  mock_pool = mock("Beanstalk::Pool")
23
- mock_pool.should_receive(:watch).with("default")
25
+ mock_pool.should_receive(:watch).with("the_queue_name")
24
26
  # Returns nil on the second call.
25
27
  mock_pool.should_receive(:reserve).and_return(mock_job, nil)
26
28
 
@@ -92,7 +94,7 @@ describe Ayl::Beanstalk::Worker do
92
94
  mock_job = mock("Beanstalk::Job")
93
95
  mock_job.should_receive(:decay)
94
96
  mock_job.should_receive(:ybody).and_return({ :type => :ayl, :code => "Dog" })
95
- mock_job.should_receive(:age).and_return(10)
97
+ mock_job.should_receive(:age).exactly(2).times.and_return(10)
96
98
 
97
99
  mock_pool = mock("Beanstalk::Pool")
98
100
  mock_pool.should_receive(:watch).with("default")
@@ -111,7 +113,7 @@ describe Ayl::Beanstalk::Worker do
111
113
  mock_job = mock("Beanstalk::Job")
112
114
  mock_job.should_receive(:delete)
113
115
  mock_job.should_receive(:ybody).and_return({ :type => :ayl, :code => "Dog" })
114
- mock_job.should_receive(:age).and_return(65)
116
+ mock_job.should_receive(:age).exactly(2).times.and_return(65)
115
117
 
116
118
  mock_pool = mock("Beanstalk::Pool")
117
119
  mock_pool.should_receive(:watch).with("default")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ayl-beanstalk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-26 00:00:00.000000000Z
12
+ date: 2012-03-06 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ayl
16
- requirement: &76745740 !ruby/object:Gem::Requirement
16
+ requirement: &75023090 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.1.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *76745740
24
+ version_requirements: *75023090
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: beanstalk-client
27
- requirement: &76745460 !ruby/object:Gem::Requirement
27
+ requirement: &75022810 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.1.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *76745460
35
+ version_requirements: *75022810
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: daemons
38
- requirement: &76745190 !ruby/object:Gem::Requirement
38
+ requirement: &75022550 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.1.0
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *76745190
46
+ version_requirements: *75022550
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
- requirement: &76744930 !ruby/object:Gem::Requirement
49
+ requirement: &75022280 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 2.3.0
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *76744930
57
+ version_requirements: *75022280
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: bundler
60
- requirement: &76744580 !ruby/object:Gem::Requirement
60
+ requirement: &75021930 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 1.0.0
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *76744580
68
+ version_requirements: *75021930
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: jeweler
71
- requirement: &76744270 !ruby/object:Gem::Requirement
71
+ requirement: &75021620 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 1.6.4
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *76744270
79
+ version_requirements: *75021620
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: rcov
82
- requirement: &76743930 !ruby/object:Gem::Requirement
82
+ requirement: &75021290 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *76743930
90
+ version_requirements: *75021290
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: pry
93
- requirement: &76743560 !ruby/object:Gem::Requirement
93
+ requirement: &75020960 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,7 +98,7 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *76743560
101
+ version_requirements: *75020960
102
102
  description: Ayl extension to provide beanstalk support.
103
103
  email: j0hnds@gmail.com
104
104
  executables:
@@ -149,7 +149,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
149
149
  version: '0'
150
150
  segments:
151
151
  - 0
152
- hash: 36129679
152
+ hash: 1045641297
153
153
  required_rubygems_version: !ruby/object:Gem::Requirement
154
154
  none: false
155
155
  requirements: