quebert 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
File without changes
data/Gemfile CHANGED
@@ -8,8 +8,8 @@ group :development do
8
8
  end
9
9
 
10
10
  group :test do
11
- gem 'ruby-debug', :platform => :ruby_18
12
- gem 'ruby-debug19', :platform => :ruby_19
11
+ # gem 'ruby-debug', :platform => :ruby_18
12
+ # gem 'ruby-debug19', :platform => :ruby_19
13
13
  gem 'activerecord', '2.3.5'
14
14
  gem 'sqlite3-ruby'
15
15
  gem 'guard-rspec'
@@ -1,10 +1,10 @@
1
1
  require 'quebert/version'
2
2
 
3
3
  module Quebert
4
+ autoload :Logging, 'quebert/logging'
4
5
  autoload :Serializer, 'quebert/serializer'
5
6
  autoload :Configuration, 'quebert/configuration'
6
7
  autoload :Timeout, 'quebert/timeout'
7
- autoload :Logging, 'quebert/logging'
8
8
  autoload :Job, 'quebert/job'
9
9
  autoload :Controller, 'quebert/controller'
10
10
  autoload :Backend, 'quebert/backend'
@@ -4,7 +4,7 @@ module Quebert
4
4
  module Instance
5
5
  class InstanceJob < Job
6
6
  def perform(klass, init_args, meth, *args)
7
- Support.constantize(klass).new(init_args).send(meth, *args)
7
+ Support.constantize(klass).new(*init_args).send(meth, *args)
8
8
  end
9
9
  end
10
10
 
@@ -29,8 +29,11 @@ module Quebert
29
29
  end
30
30
  end
31
31
 
32
+ def initialize(host, *args)
33
+ super Array(host), *args
34
+ end
32
35
  def self.configure(opts={})
33
- opts[:host] ||= '127.0.0.1:11300'
36
+ opts[:host] ||= ['127.0.0.1:11300']
34
37
  new(opts[:host], opts[:tube])
35
38
  end
36
39
  end
@@ -68,7 +68,7 @@ module Quebert
68
68
  protected
69
69
  def retry_with_delay
70
70
  delay = TIMEOUT_RETRY_DELAY_SEED + TIMEOUT_RETRY_GROWTH_RATE**beanstalk_job.stats["releases"].to_i
71
-
71
+
72
72
  if delay > MAX_TIMEOUT_RETRY_DELAY
73
73
  beanstalk_job.bury
74
74
  log "Max retry delay exceeded. Burrying job."
@@ -11,6 +11,11 @@ module Quebert
11
11
  DEFAULT_JOB_DELAY = 0
12
12
  DEFAULT_JOB_TTR = 10
13
13
 
14
+ # A buffer time in seconds added to the Beanstalk TTR for Quebert to do its own job cleanup
15
+ # The job will perform based on the Beanstalk TTR, but Beanstalk hangs on to the job just a
16
+ # little longer so that Quebert can bury the job or schedule a retry with the appropriate delay
17
+ QUEBERT_TTR_BUFFER = 1
18
+
14
19
  NotImplemented = Class.new(StandardError)
15
20
 
16
21
  Action = Class.new(Exception)
@@ -58,7 +63,7 @@ module Quebert
58
63
  end
59
64
 
60
65
  def enqueue
61
- self.class.backend.put self, @priority, @delay, @ttr
66
+ self.class.backend.put self, @priority, @delay, @ttr + QUEBERT_TTR_BUFFER
62
67
  end
63
68
 
64
69
  def to_json
@@ -1,8 +1,6 @@
1
- require 'logger'
2
-
3
1
  module Quebert
4
2
  module Logging
5
- protected
3
+ protected
6
4
  def logger
7
5
  @logger ||= Quebert.logger
8
6
  end
@@ -1,3 +1,3 @@
1
1
  module Quebert
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
@@ -23,5 +23,5 @@ Gem::Specification.new do |s|
23
23
  s.add_runtime_dependency "json"
24
24
  s.add_runtime_dependency "beanstalk-client"
25
25
 
26
- s.add_development_dependency 'rspec', '1.3.0'
26
+ s.add_development_dependency 'rspec', '2.7.0'
27
27
  end
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
1
+ require 'spec_helper'
2
2
 
3
3
  describe AsyncSender::Class do
4
4
 
@@ -31,7 +31,7 @@ describe AsyncSender::Class do
31
31
 
32
32
  it "should async send instance methods" do
33
33
  Greeter.new("brad").async_send(:hi, 'stunning')
34
- @q.reserve.perform.should eql(Greeter.new("brad").send(:hi, 'stunning'))
34
+ @q.reserve.perform.should eql(Greeter.new("brad").hi('stunning'))
35
35
  end
36
36
 
37
37
  end
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
1
+ require 'spec_helper'
2
2
 
3
3
  describe Backend do
4
4
  it "should have register backends" do
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
1
+ require 'spec_helper'
2
2
 
3
3
  describe CommandLineRunner do
4
4
  before(:all) do
@@ -53,7 +53,7 @@ describe CommandLineRunner do
53
53
  it "should run config file" do
54
54
  clean_file './super_awesome.rb', "raise 'SuperAwesome'" do
55
55
  lambda{
56
- CommandLineRunner.dispatch(%w(worker --config super_awesome.rb))
56
+ CommandLineRunner.dispatch(%w(worker --config ./super_awesome.rb))
57
57
  }.should raise_exception('SuperAwesome')
58
58
  end
59
59
  end
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
1
+ require 'spec_helper'
2
2
 
3
3
  describe Configuration do
4
4
  context "from hash" do
@@ -10,7 +10,7 @@ describe Configuration do
10
10
  backend = @config.backend
11
11
  backend.should be_instance_of(Quebert::Backend::Beanstalk)
12
12
  # Blech, gross nastiness in their lib, but we need to look in to see if this stuff as configed
13
- backend.instance_variable_get('@addrs').should eql('localhost:11300')
13
+ backend.instance_variable_get('@addrs').should eql(['localhost:11300'])
14
14
  backend.instance_variable_get('@default_tube').should eql('quebert-config-test')
15
15
  end
16
16
 
@@ -1,5 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
- require 'ruby-debug'
1
+ require 'spec_helper'
3
2
 
4
3
  describe Controller::Base do
5
4
  it "should perform job" do
@@ -73,7 +72,8 @@ describe Controller::Beanstalk do
73
72
  end
74
73
 
75
74
  it "should retry a job with a delay and then bury" do
76
- @q.put TimeoutJob.new
75
+ TimeoutJob.backend = @q
76
+ TimeoutJob.new.enqueue
77
77
  @q.peek_ready.should_not be_nil
78
78
  job = @q.reserve
79
79
  job.beanstalk_job.stats["releases"].should eql(0)
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
1
+ require 'spec_helper'
2
2
 
3
3
  describe Quebert::Job do
4
4
 
@@ -73,7 +73,7 @@ describe Quebert::Job do
73
73
  job = @q.reserve
74
74
  job.beanstalk_job.pri.should eql(1)
75
75
  job.beanstalk_job.delay.should eql(2)
76
- job.beanstalk_job.ttr.should eql(300)
76
+ job.beanstalk_job.ttr.should eql(300 + Job::QUEBERT_TTR_BUFFER)
77
77
  end
78
78
 
79
79
  it "should enqueue and honor beanstalk options" do
@@ -81,7 +81,7 @@ describe Quebert::Job do
81
81
  job = @q.reserve
82
82
  job.beanstalk_job.pri.should eql(1)
83
83
  job.beanstalk_job.delay.should eql(2)
84
- job.beanstalk_job.ttr.should eql(300)
84
+ job.beanstalk_job.ttr.should eql(300 + Job::QUEBERT_TTR_BUFFER)
85
85
  end
86
86
  end
87
87
  end
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
1
+ require 'spec_helper'
2
2
 
3
3
  describe Quebert do
4
4
 
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
1
+ require 'spec_helper'
2
2
 
3
3
  describe Serializer::ActiveRecord do
4
4
  context "persisted" do
@@ -5,13 +5,9 @@ $LOAD_PATH.unshift(File.dirname(__FILE__))
5
5
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
6
 
7
7
  require 'quebert'
8
- require 'spec'
9
- require 'spec/autorun'
8
+ require 'quebert/logging'
10
9
  require 'logger'
11
10
 
12
- Spec::Runner.configure do |config|
13
- end
14
-
15
11
  include Quebert
16
12
  Quebert.config.logger = Logger.new('/dev/null') # Shhh...
17
13
 
@@ -17,10 +17,9 @@ class BuryJob < Quebert::Job
17
17
  end
18
18
 
19
19
  class TimeoutJob < Quebert::Job
20
- def perform!
21
- # 1 second TTR
22
- @ttr = 1
20
+ def initialize
23
21
  super
22
+ @ttr = 1
24
23
  end
25
24
 
26
25
  def perform
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
1
+ require 'spec_helper'
2
2
 
3
3
  describe Support::ClassRegistry do
4
4
  Super = Class.new
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
1
+ require 'spec_helper'
2
2
 
3
3
  describe Worker do
4
4
  before(:each) do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quebert
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 1
10
- version: 1.0.1
9
+ - 2
10
+ version: 1.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Brad Gessler
@@ -17,8 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2012-03-09 00:00:00 -08:00
21
- default_executable:
20
+ date: 2012-04-10 00:00:00 Z
22
21
  dependencies:
23
22
  - !ruby/object:Gem::Dependency
24
23
  name: json
@@ -56,12 +55,12 @@ dependencies:
56
55
  requirements:
57
56
  - - "="
58
57
  - !ruby/object:Gem::Version
59
- hash: 27
58
+ hash: 19
60
59
  segments:
61
- - 1
62
- - 3
60
+ - 2
61
+ - 7
63
62
  - 0
64
- version: 1.3.0
63
+ version: 2.7.0
65
64
  type: :development
66
65
  version_requirements: *id003
67
66
  description: A worker queue framework built around beanstalkd
@@ -77,6 +76,7 @@ files:
77
76
  - .document
78
77
  - .gitignore
79
78
  - .rbenv-version
79
+ - .rspec
80
80
  - Gemfile
81
81
  - Guardfile
82
82
  - LICENSE
@@ -116,13 +116,11 @@ files:
116
116
  - spec/job_spec.rb
117
117
  - spec/quebert_spec.rb
118
118
  - spec/serializer_spec.rb
119
- - spec/spec.opts
120
119
  - spec/spec_helper.rb
121
120
  - spec/support/active_record.rb
122
121
  - spec/support/jobs.rb
123
122
  - spec/support_spec.rb
124
123
  - spec/worker_spec.rb
125
- has_rdoc: true
126
124
  homepage: http://github.com/polleverywhere/quebert
127
125
  licenses: []
128
126
 
@@ -152,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
150
  requirements: []
153
151
 
154
152
  rubyforge_project: quebert
155
- rubygems_version: 1.6.2
153
+ rubygems_version: 1.8.21
156
154
  signing_key:
157
155
  specification_version: 3
158
156
  summary: A worker queue framework built around beanstalkd
@@ -165,7 +163,6 @@ test_files:
165
163
  - spec/job_spec.rb
166
164
  - spec/quebert_spec.rb
167
165
  - spec/serializer_spec.rb
168
- - spec/spec.opts
169
166
  - spec/spec_helper.rb
170
167
  - spec/support/active_record.rb
171
168
  - spec/support/jobs.rb