resque-pool-vinted 0.4.0.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,41 @@
1
+ resque-pool.yml(5) -- resque-pool pool configuration
2
+ =====================================================
3
+
4
+ ## SYNOPSIS
5
+
6
+ `resque-pool.yml`<br>
7
+ `config/resque-pool.yml`
8
+
9
+ ## DESCRIPTION
10
+
11
+ resque-pool(1) reads pool configuration data from `resque-pool.yml` (or
12
+ the file specified with `-c` on the command line). The file contains queue-worker-count pairs, one per line. The configuration file supports both
13
+ using root level defaults as well as environment specific overrides
14
+ (`RACK_ENV`, `RAILS_ENV`, and `RESQUE_ENV` environment variables can be used
15
+ to determine environment).
16
+
17
+ An example configuration
18
+
19
+ foo: 1
20
+ bar: 2
21
+ "foo,bar,baz": 1
22
+
23
+ production:
24
+ "foo,bar,baz": 4
25
+
26
+ will create 7 workers in production and 4 in other environment configurations.
27
+ The simpler worker definition `foo: 1` will create 1 worker for the `foo`
28
+ queue, the more complicated `foo,bar,baz: 1` will create 1 worker for the
29
+ queues `foo`, `bar` and `baz`.
30
+
31
+ ## AUTHOR
32
+
33
+ Nicholas Evans
34
+
35
+ ## COPYRIGHT
36
+
37
+ Copyright (C) 2010 by Nicholas Evans <nick@ekenosen.net>, et al.
38
+
39
+ ## SEE ALSO
40
+
41
+ resque-pool(1)
@@ -0,0 +1,6 @@
1
+ RESQUE_POOL_CONFIG = {
2
+ 'foo' => 1,
3
+ 'bar' => 1,
4
+ 'baz' => 1,
5
+ 'foo,bar,baz' => 4,
6
+ }
@@ -0,0 +1 @@
1
+ foo: <%= 1+1 %>
@@ -0,0 +1,13 @@
1
+ foo: 1
2
+
3
+ production:
4
+ "foo,bar": 10
5
+
6
+ development:
7
+ "foo,bar": 4
8
+ "baz": 23
9
+
10
+ test:
11
+ "bar": 5
12
+ "foo,bar": 3
13
+
@@ -0,0 +1,202 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.configure do |config|
4
+ config.after {
5
+ Object.send(:remove_const, :RAILS_ENV) if defined? RAILS_ENV
6
+ ENV.delete 'RACK_ENV'
7
+ ENV.delete 'RAILS_ENV'
8
+ ENV.delete 'RESQUE_ENV'
9
+ ENV.delete 'RESQUE_POOL_CONFIG'
10
+ }
11
+ end
12
+
13
+ describe Resque::Pool, "when loading a simple pool configuration" do
14
+ let(:config) do
15
+ { 'foo' => 1, 'bar' => 2, 'foo,bar' => 3, 'bar,foo' => 4, }
16
+ end
17
+ subject { Resque::Pool.new(config) }
18
+
19
+ context "when ENV['RACK_ENV'] is set" do
20
+ before { ENV['RACK_ENV'] = 'development' }
21
+
22
+ it "should load the values from the Hash" do
23
+ subject.config["foo"].should == 1
24
+ subject.config["bar"].should == 2
25
+ subject.config["foo,bar"].should == 3
26
+ subject.config["bar,foo"].should == 4
27
+ end
28
+ end
29
+
30
+ end
31
+
32
+ describe Resque::Pool, "when loading the pool configuration from a Hash" do
33
+
34
+ let(:config) do
35
+ {
36
+ 'foo' => 8,
37
+ 'test' => { 'bar' => 10, 'foo,bar' => 12 },
38
+ 'development' => { 'baz' => 14, 'foo,bar' => 16 },
39
+ }
40
+ end
41
+
42
+ subject { Resque::Pool.new(config) }
43
+
44
+ context "when RAILS_ENV is set" do
45
+ before { RAILS_ENV = "test" }
46
+
47
+ it "should load the default values from the Hash" do
48
+ subject.config["foo"].should == 8
49
+ end
50
+
51
+ it "should merge the values for the correct RAILS_ENV" do
52
+ subject.config["bar"].should == 10
53
+ subject.config["foo,bar"].should == 12
54
+ end
55
+
56
+ it "should not load the values for the other environments" do
57
+ subject.config["foo,bar"].should == 12
58
+ subject.config["baz"].should be_nil
59
+ end
60
+
61
+ end
62
+
63
+ context "when Rails.env is set" do
64
+ before(:each) do
65
+ module Rails; end
66
+ Rails.stub(:env).and_return('test')
67
+ end
68
+
69
+ it "should load the default values from the Hash" do
70
+ subject.config["foo"].should == 8
71
+ end
72
+
73
+ it "should merge the values for the correct RAILS_ENV" do
74
+ subject.config["bar"].should == 10
75
+ subject.config["foo,bar"].should == 12
76
+ end
77
+
78
+ it "should not load the values for the other environments" do
79
+ subject.config["foo,bar"].should == 12
80
+ subject.config["baz"].should be_nil
81
+ end
82
+
83
+ after(:all) { Object.send(:remove_const, :Rails) }
84
+ end
85
+
86
+
87
+ context "when ENV['RESQUE_ENV'] is set" do
88
+ before { ENV['RESQUE_ENV'] = 'development' }
89
+ it "should load the config for that environment" do
90
+ subject.config["foo"].should == 8
91
+ subject.config["foo,bar"].should == 16
92
+ subject.config["baz"].should == 14
93
+ subject.config["bar"].should be_nil
94
+ end
95
+ end
96
+
97
+ context "when there is no environment" do
98
+ it "should load the default values only" do
99
+ subject.config["foo"].should == 8
100
+ subject.config["bar"].should be_nil
101
+ subject.config["foo,bar"].should be_nil
102
+ subject.config["baz"].should be_nil
103
+ end
104
+ end
105
+
106
+ end
107
+
108
+ describe Resque::Pool, "given no configuration" do
109
+ subject { Resque::Pool.new(nil) }
110
+ it "should have no worker types" do
111
+ subject.config.should == {}
112
+ end
113
+ end
114
+
115
+ describe Resque::Pool, "when loading the pool configuration from a file" do
116
+
117
+ subject { Resque::Pool.new("spec/resque-pool.yml") }
118
+
119
+ context "when RAILS_ENV is set" do
120
+ before { RAILS_ENV = "test" }
121
+
122
+ it "should load the default YAML" do
123
+ subject.config["foo"].should == 1
124
+ end
125
+
126
+ it "should merge the YAML for the correct RAILS_ENV" do
127
+ subject.config["bar"].should == 5
128
+ subject.config["foo,bar"].should == 3
129
+ end
130
+
131
+ it "should not load the YAML for the other environments" do
132
+ subject.config["foo"].should == 1
133
+ subject.config["bar"].should == 5
134
+ subject.config["foo,bar"].should == 3
135
+ subject.config["baz"].should be_nil
136
+ end
137
+
138
+ end
139
+
140
+ context "when ENV['RACK_ENV'] is set" do
141
+ before { ENV['RACK_ENV'] = 'development' }
142
+ it "should load the config for that environment" do
143
+ subject.config["foo"].should == 1
144
+ subject.config["foo,bar"].should == 4
145
+ subject.config["baz"].should == 23
146
+ subject.config["bar"].should be_nil
147
+ end
148
+ end
149
+
150
+ context "when there is no environment" do
151
+ it "should load the default values only" do
152
+ subject.config["foo"].should == 1
153
+ subject.config["bar"].should be_nil
154
+ subject.config["foo,bar"].should be_nil
155
+ subject.config["baz"].should be_nil
156
+ end
157
+ end
158
+
159
+ context "when a custom file is specified" do
160
+ before { ENV["RESQUE_POOL_CONFIG"] = 'spec/resque-pool-custom.yml.erb' }
161
+ subject { Resque::Pool.new(Resque::Pool.choose_config_file) }
162
+ it "should find the right file, and parse the ERB" do
163
+ subject.config["foo"].should == 2
164
+ end
165
+ end
166
+
167
+ end
168
+
169
+ describe Resque::Pool, "given after_prefork hook" do
170
+ subject { Resque::Pool.new(nil) }
171
+
172
+ context "with a single hook" do
173
+ before { Resque::Pool.after_prefork { @called = true } }
174
+
175
+ it "should call prefork" do
176
+ subject.call_after_prefork!
177
+ @called.should == true
178
+ end
179
+ end
180
+
181
+ context "with a single hook by attribute writer" do
182
+ before { Resque::Pool.after_prefork = Proc.new { @called = true } }
183
+
184
+ it "should call prefork" do
185
+ subject.call_after_prefork!
186
+ @called.should == true
187
+ end
188
+ end
189
+
190
+ context "with multiple hooks" do
191
+ before {
192
+ Resque::Pool.after_prefork { @called_first = true }
193
+ Resque::Pool.after_prefork { @called_second = true }
194
+ }
195
+
196
+ it "should call both" do
197
+ subject.call_after_prefork!
198
+ @called_first.should == true
199
+ @called_second.should == true
200
+ end
201
+ end
202
+ end
@@ -0,0 +1,3 @@
1
+ require 'rspec'
2
+ $LOAD_PATH << File.expand_path("../lib", File.dirname(__FILE__))
3
+ require 'resque/pool'
metadata ADDED
@@ -0,0 +1,195 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: resque-pool-vinted
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.0.rc1
5
+ platform: ruby
6
+ authors:
7
+ - nicholas a. evans
8
+ - Tomas Varaneckas
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-04-29 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: resque
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ~>
19
+ - !ruby/object:Gem::Version
20
+ version: '1.22'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ version: '1.22'
28
+ - !ruby/object:Gem::Dependency
29
+ name: trollop
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ~>
33
+ - !ruby/object:Gem::Version
34
+ version: '1.16'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ~>
40
+ - !ruby/object:Gem::Version
41
+ version: '1.16'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rake
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rspec
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ~>
61
+ - !ruby/object:Gem::Version
62
+ version: '2.10'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: '2.10'
70
+ - !ruby/object:Gem::Dependency
71
+ name: cucumber
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ version: '1.2'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ~>
82
+ - !ruby/object:Gem::Version
83
+ version: '1.2'
84
+ - !ruby/object:Gem::Dependency
85
+ name: aruba
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ~>
89
+ - !ruby/object:Gem::Version
90
+ version: 0.4.11
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ~>
96
+ - !ruby/object:Gem::Version
97
+ version: 0.4.11
98
+ - !ruby/object:Gem::Dependency
99
+ name: bundler
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ~>
103
+ - !ruby/object:Gem::Version
104
+ version: '1.0'
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ~>
110
+ - !ruby/object:Gem::Version
111
+ version: '1.0'
112
+ - !ruby/object:Gem::Dependency
113
+ name: ronn
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - '>='
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ description: |2
127
+ quickly and easily fork a pool of resque workers,
128
+ saving memory (w/REE) and monitoring their uptime
129
+ email:
130
+ - tomas.varaneckas@gmail.com
131
+ executables:
132
+ - resque-pool
133
+ extensions: []
134
+ extra_rdoc_files: []
135
+ files:
136
+ - README.md
137
+ - Rakefile
138
+ - LICENSE.txt
139
+ - Changelog.md
140
+ - lib/resque/pool/cli.rb
141
+ - lib/resque/pool/logging.rb
142
+ - lib/resque/pool/pooled_worker.rb
143
+ - lib/resque/pool/tasks.rb
144
+ - lib/resque/pool/version.rb
145
+ - lib/resque/pool.rb
146
+ - bin/resque-pool
147
+ - man/resque-pool.1
148
+ - man/resque-pool.1.ronn
149
+ - man/resque-pool.yml.5
150
+ - man/resque-pool.yml.5.ronn
151
+ - features/basic_daemon_config.feature
152
+ - features/step_definitions/daemon_steps.rb
153
+ - features/step_definitions/resque-pool_steps.rb
154
+ - features/support/aruba_daemon_support.rb
155
+ - features/support/env.rb
156
+ - spec/mock_config.rb
157
+ - spec/resque-pool-custom.yml.erb
158
+ - spec/resque-pool.yml
159
+ - spec/resque_pool_spec.rb
160
+ - spec/spec_helper.rb
161
+ homepage: http://github.com/vinted/resque-pool
162
+ licenses:
163
+ - MIT
164
+ metadata: {}
165
+ post_install_message:
166
+ rdoc_options: []
167
+ require_paths:
168
+ - lib
169
+ required_ruby_version: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - '>='
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ required_rubygems_version: !ruby/object:Gem::Requirement
175
+ requirements:
176
+ - - '>'
177
+ - !ruby/object:Gem::Version
178
+ version: 1.3.1
179
+ requirements: []
180
+ rubyforge_project:
181
+ rubygems_version: 2.0.6
182
+ signing_key:
183
+ specification_version: 4
184
+ summary: quickly and easily fork a pool of resque workers
185
+ test_files:
186
+ - spec/mock_config.rb
187
+ - spec/resque_pool_spec.rb
188
+ - spec/spec_helper.rb
189
+ - spec/resque-pool.yml
190
+ - features/step_definitions/daemon_steps.rb
191
+ - features/step_definitions/resque-pool_steps.rb
192
+ - features/support/aruba_daemon_support.rb
193
+ - features/support/env.rb
194
+ - features/basic_daemon_config.feature
195
+ has_rdoc: