heroku-qc-autoscale 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -6,13 +6,13 @@ Add to a Rails 3.x project to auto scale QueueClassic workers on heroku.
6
6
  **WARNING: USE AT OWN RISK! THIS GEM IS CONSIDERED EXTREME ALPHA!**
7
7
 
8
8
  [![Build Status](https://secure.travis-ci.org/zerobearing2/heroku-qc-autoscale.png)](http://travis-ci.org/zerobearing2/heroku-qc-autoscale)
9
-
9
+ [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/zerobearing2/heroku-qc-autoscale)
10
10
 
11
11
  Usage
12
12
  -----
13
13
 
14
14
  Install as gem
15
-
15
+
16
16
  gem install heroku-qc-autoscale
17
17
 
18
18
  Add to Gemfile
@@ -31,12 +31,22 @@ Create config/initializers/qc_autoscale.rb
31
31
 
32
32
  Autoscale.activate! if Rails.env.production?
33
33
 
34
- Queue jobs as normal with QueueClassic. Based on your scale table, it will recalculate the
34
+ Queue jobs as normal with QueueClassic. Based on your scale table, it will recalculate the
35
35
  workers required after each QC#enqueue, and QC#delete.
36
36
 
37
37
  QC.enqueue("Time.now")
38
38
 
39
39
 
40
+ TODO
41
+ ----
42
+
43
+ - remove Rails dependencies
44
+ - remove ActiveSupport dependencies
45
+ - when queue is emptied, scale workers to "min" after X time elapses.
46
+ - rake task to scale workers to "min" manually
47
+ - enable/disable scaling at runtime
48
+
49
+
40
50
  Meta
41
51
  ----
42
52
 
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
7
7
  s.version = Heroku::QC::Autoscale::VERSION
8
8
  s.authors = ["David Bradford"]
9
9
  s.email = ["david@zerobearing.com"]
10
- s.homepage = ""
10
+ s.homepage = "https://github.com/zerobearing2/heroku-qc-autoscale"
11
11
  s.summary = %q{Auto scale your QueueClassic workers on Heroku. Inspired by mirthlab's Resque auto scale gem.}
12
12
  s.description = %q{Add to a Rails 3.x project to auto scale QueueClassic workers on heroku.}
13
13
 
@@ -20,9 +20,9 @@ Gem::Specification.new do |s|
20
20
 
21
21
  # specify any dependencies here; for example:
22
22
  s.add_runtime_dependency "heroku-api", "~> 0.3.2"
23
- s.add_runtime_dependency "activesupport", "~> 3.1.7"
23
+ s.add_runtime_dependency "activesupport", "~> 3.2"
24
24
  s.add_runtime_dependency "i18n", "~> 0.6.0"
25
- s.add_runtime_dependency "queue_classic", "~> 2.0.1"
25
+ s.add_runtime_dependency "queue_classic", "~> 2.0"
26
26
 
27
27
  s.add_development_dependency "minitest", "~> 3.3.0"
28
28
  s.add_development_dependency 'rake'
@@ -1,6 +1,6 @@
1
1
  module Autoscale
2
2
  class Heroku
3
-
3
+
4
4
  class << self
5
5
 
6
6
  def workers
@@ -42,11 +42,14 @@ module Autoscale
42
42
 
43
43
  def params
44
44
  {
45
- api_key: Autoscale.api_key || ENV['HEROKU_API_KEY'],
46
- mock: Autoscale.mock || false
45
+ api_key: Autoscale.api_key || ENV['HEROKU_API_KEY'],
46
+ connect_timeout: Autoscale.connect_timeout,
47
+ read_timeout: Autoscale.read_timeout,
48
+ write_timeout: Autoscale.write_timeout,
49
+ mock: Autoscale.mock || false
47
50
  }
48
51
  end
49
-
52
+
50
53
  # the app to scale
51
54
  def app
52
55
  Autoscale.app
@@ -68,5 +71,5 @@ module Autoscale
68
71
  end
69
72
 
70
73
  end
71
-
72
- end
74
+
75
+ end
@@ -9,13 +9,25 @@ require "autoscale/queue_classic/callbacks"
9
9
  require "heroku-qc-autoscale/version"
10
10
 
11
11
  module Autoscale
12
- mattr_accessor :api_key, :app, :mock, :scale, :min
12
+ mattr_accessor :api_key, :app, :mock, :scale, :min, :connect_timeout, :read_timeout, :write_timeout
13
13
 
14
14
  # config and activate QC bindings
15
15
  def self.config(&block)
16
16
  yield(self)
17
17
  end
18
18
 
19
+ def self.connect_timeout
20
+ @@connect_timeout||5
21
+ end
22
+
23
+ def self.read_timeout
24
+ @@read_timeout||15
25
+ end
26
+
27
+ def self.write_timeout
28
+ @@write_timeout||15
29
+ end
30
+
19
31
  # activate QC queue callbacks
20
32
  def self.activate!
21
33
  QC::Queue.send(:include, Autoscale::QueueClassic::QueueCallbacks)
@@ -1,7 +1,7 @@
1
1
  module Heroku
2
2
  module QC
3
3
  module Autoscale
4
- VERSION = "0.0.6"
4
+ VERSION = "0.0.7"
5
5
  end
6
6
  end
7
7
  end
@@ -19,4 +19,23 @@ describe Autoscale do
19
19
  subject.min.must_equal 0
20
20
  end
21
21
 
22
- end
22
+ describe "configure" do
23
+ subject { Autoscale }
24
+
25
+ it "should set connect timeout to 15s" do
26
+ Autoscale.connect_timeout = 15
27
+ subject.connect_timeout.must_equal(15)
28
+ end
29
+
30
+ it "should set read timeout to 60s" do
31
+ Autoscale.read_timeout = 60
32
+ subject.read_timeout.must_equal(60)
33
+ end
34
+
35
+ it "should set write timeout to 60s" do
36
+ Autoscale.write_timeout = 60
37
+ subject.write_timeout.must_equal(60)
38
+ end
39
+ end
40
+
41
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heroku-qc-autoscale
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
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-08-09 00:00:00.000000000 Z
12
+ date: 2012-11-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: heroku-api
@@ -34,7 +34,7 @@ dependencies:
34
34
  requirements:
35
35
  - - ~>
36
36
  - !ruby/object:Gem::Version
37
- version: 3.1.7
37
+ version: '3.2'
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,7 +42,7 @@ dependencies:
42
42
  requirements:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
- version: 3.1.7
45
+ version: '3.2'
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: i18n
48
48
  requirement: !ruby/object:Gem::Requirement
@@ -66,7 +66,7 @@ dependencies:
66
66
  requirements:
67
67
  - - ~>
68
68
  - !ruby/object:Gem::Version
69
- version: 2.0.1
69
+ version: '2.0'
70
70
  type: :runtime
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
@@ -74,7 +74,7 @@ dependencies:
74
74
  requirements:
75
75
  - - ~>
76
76
  - !ruby/object:Gem::Version
77
- version: 2.0.1
77
+ version: '2.0'
78
78
  - !ruby/object:Gem::Dependency
79
79
  name: minitest
80
80
  requirement: !ruby/object:Gem::Requirement
@@ -146,7 +146,7 @@ files:
146
146
  - test/autoscale_test.rb
147
147
  - test/support/qc_helper.rb
148
148
  - test/test_helper.rb
149
- homepage: ''
149
+ homepage: https://github.com/zerobearing2/heroku-qc-autoscale
150
150
  licenses: []
151
151
  post_install_message:
152
152
  rdoc_options: []
@@ -160,7 +160,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
160
160
  version: '0'
161
161
  segments:
162
162
  - 0
163
- hash: 2193298556490401975
163
+ hash: 1271731275961861926
164
164
  required_rubygems_version: !ruby/object:Gem::Requirement
165
165
  none: false
166
166
  requirements:
@@ -169,10 +169,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
169
169
  version: '0'
170
170
  segments:
171
171
  - 0
172
- hash: 2193298556490401975
172
+ hash: 1271731275961861926
173
173
  requirements: []
174
174
  rubyforge_project: heroku-qc-autoscale
175
- rubygems_version: 1.8.21
175
+ rubygems_version: 1.8.23
176
176
  signing_key:
177
177
  specification_version: 3
178
178
  summary: Auto scale your QueueClassic workers on Heroku. Inspired by mirthlab's Resque