workless 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -9,6 +9,7 @@ By adding the gem to your project and configuring our Heroku app with some confi
9
9
 
10
10
  ## Updates
11
11
 
12
+ * Version 1.1.3 includes changes by @radanskoric to reduce number of heroku api calls
12
13
  * Version 1.1.2 includes a change by @davidakachaos to scale workers using after_commit
13
14
  * Version 1.1.1 includes a fix from @filiptepper and @fixr to correctly scale workers
14
15
  * Version 1.1.0 has been released, this adds support for scaling using multiple workers thanks to @jaimeiniesta and @davidakachaos.
@@ -32,21 +33,21 @@ Add the workless gem and the delayed_job gem to your project Gemfile and update
32
33
 
33
34
  <pre>
34
35
  gem "delayed_job", "2.0.7"
35
- gem "workless", "~> 1.1.1"
36
+ gem "workless", "~> 1.1.3"
36
37
  </pre>
37
38
 
38
39
  ### For rails 3.x with delayed_job 2.1.x
39
40
 
40
41
  <pre>
41
42
  gem "delayed_job", "~> 2.1.4"
42
- gem "workless", "~> 1.1.1"
43
+ gem "workless", "~> 1.1.3"
43
44
  </pre>
44
45
 
45
46
  ### For rails 3.x with latest delayed_job 3.x using active record
46
47
 
47
48
  <pre>
48
49
  gem "delayed_job_active_record"
49
- gem "workless", "~> 1.1.1"
50
+ gem "workless", "~> 1.1.3"
50
51
  </pre>
51
52
 
52
53
  If you don't specify delayed_job in your Gemfile workless will bring it in, most likly the latest version (3.0.1)
@@ -1,3 +1,4 @@
1
1
  Delayed::Worker.max_attempts = 3
2
2
  Delayed::Backend::ActiveRecord::Job.send(:include, Delayed::Workless::Scaler) if defined?(Delayed::Backend::ActiveRecord::Job)
3
3
  Delayed::Backend::Mongoid::Job.send(:include, Delayed::Workless::Scaler) if defined?(Delayed::Backend::Mongoid::Job)
4
+ Delayed::Backend::MongoMapper::Job.send(:include, Delayed::Workless::Scaler) if defined?(Delayed::Backend::MongoMapper::Job)
@@ -9,10 +9,18 @@ module Delayed
9
9
 
10
10
  def self.included(base)
11
11
  base.send :extend, ClassMethods
12
- base.class_eval do
13
- after_commit "self.class.scaler.down", :on => :destroy
14
- after_commit "self.class.scaler.up", :on => :create
15
- after_commit "self.class.scaler.down", :on => :update, :unless => Proc.new {|r| r.failed_at.nil? }
12
+ unless base.to_s =~ /ActiveRecord/
13
+ base.class_eval do
14
+ after_destroy "self.class.scaler.down"
15
+ after_create "self.class.scaler.up"
16
+ after_update "self.class.scaler.down", :unless => Proc.new {|r| r.failed_at.nil? }
17
+ end
18
+ else
19
+ base.class_eval do
20
+ after_commit "self.class.scaler.down", :on => :destroy
21
+ after_commit "self.class.scaler.up", :on => :create
22
+ after_commit "self.class.scaler.down", :on => :update, :unless => Proc.new {|r| r.failed_at.nil? }
23
+ end
16
24
  end
17
25
 
18
26
  end
@@ -13,7 +13,7 @@ module Delayed
13
13
  end
14
14
 
15
15
  def self.down
16
- client.put_workers(ENV['APP_NAME'], 0) unless self.workers == 0 or self.jobs.count > 0
16
+ client.put_workers(ENV['APP_NAME'], 0) unless self.jobs.count > 0 or self.workers == 0
17
17
  end
18
18
 
19
19
  def self.workers
@@ -7,11 +7,11 @@ module Delayed
7
7
  extend Delayed::Workless::Scaler::HerokuClient
8
8
 
9
9
  def self.up
10
- client.post_ps_scale(ENV['APP_NAME'], 'worker', self.workers_needed) if self.workers < self.workers_needed
10
+ client.post_ps_scale(ENV['APP_NAME'], 'worker', self.workers_needed) if self.workers_needed > self.min_workers and self.workers < self.workers_needed
11
11
  end
12
12
 
13
13
  def self.down
14
- client.post_ps_scale(ENV['APP_NAME'], 'worker', self.min_workers) unless self.workers == self.min_workers or self.jobs.count > 0
14
+ client.post_ps_scale(ENV['APP_NAME'], 'worker', self.min_workers) unless self.jobs.count > 0 or self.workers == self.min_workers
15
15
  end
16
16
 
17
17
  def self.workers
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: workless
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: