qless-pool 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,46 @@
1
+ .\" generated with Ronn/v0.7.3
2
+ .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
+ .
4
+ .TH "QLESS\-POOL\.YML" "5" "May 2012" "QLESS-POOL 0.3.0.DEV" "QLESS-POOL"
5
+ .
6
+ .SH "NAME"
7
+ \fBqless\-pool\.yml\fR \- qless\-pool pool configuration
8
+ .
9
+ .SH "SYNOPSIS"
10
+ \fBqless\-pool\.yml\fR
11
+ .
12
+ .br
13
+ \fBconfig/qless\-pool\.yml\fR
14
+ .
15
+ .SH "DESCRIPTION"
16
+ qless\-pool(1) reads pool configuration data from \fBqless\-pool\.yml\fR (or the file specified with \fB\-c\fR on the command line)\. The file contains queue\-worker\-count pairs, one per line\. The configuration file supports both using root level defaults as well as environment specific overrides (\fBRACK_ENV\fR, \fBRAILS_ENV\fR, and \fBQLESS_ENV\fR environment variables can be used to determine environment)\.
17
+ .
18
+ .P
19
+ An example configuration
20
+ .
21
+ .IP "" 4
22
+ .
23
+ .nf
24
+
25
+ foo: 1
26
+ bar: 2
27
+ "foo,bar,baz": 1
28
+
29
+ production:
30
+ "foo,bar,baz": 4
31
+ .
32
+ .fi
33
+ .
34
+ .IP "" 0
35
+ .
36
+ .P
37
+ will create 7 workers in production and 4 in other environment configurations\. The simpler worker definition \fBfoo: 1\fR will create 1 worker for the \fBfoo\fR queue, the more complicated \fBfoo,bar,baz: 1\fR will create 1 worker for the queues \fBfoo\fR, \fBbar\fR and \fBbaz\fR\.
38
+ .
39
+ .SH "AUTHOR"
40
+ Nicholas Evans
41
+ .
42
+ .SH "COPYRIGHT"
43
+ Copyright (C) 2010 by Nicholas Evans \fInick@ekenosen\.net\fR, et al\.
44
+ .
45
+ .SH "SEE ALSO"
46
+ qless\-pool(1)
@@ -0,0 +1,41 @@
1
+ qless-pool.yml(5) -- qless-pool pool configuration
2
+ =====================================================
3
+
4
+ ## SYNOPSIS
5
+
6
+ `qless-pool.yml`<br>
7
+ `config/qless-pool.yml`
8
+
9
+ ## DESCRIPTION
10
+
11
+ qless-pool(1) reads pool configuration data from `qless-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 `QLESS_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
+ qless-pool(1)
@@ -0,0 +1,6 @@
1
+ QLESS_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,166 @@
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 'QLESS_ENV'
9
+ }
10
+ end
11
+
12
+ describe Qless::Pool, "when loading a simple pool configuration" do
13
+ let(:config) do
14
+ { 'foo' => 1, 'bar' => 2, 'foo,bar' => 3, 'bar,foo' => 4, }
15
+ end
16
+ subject { Qless::Pool.new(config) }
17
+
18
+ context "when ENV['RACK_ENV'] is set" do
19
+ before { ENV['RACK_ENV'] = 'development' }
20
+
21
+ it "should load the values from the Hash" do
22
+ subject.config["foo"].should == 1
23
+ subject.config["bar"].should == 2
24
+ subject.config["foo,bar"].should == 3
25
+ subject.config["bar,foo"].should == 4
26
+ end
27
+ end
28
+
29
+ end
30
+
31
+ describe Qless::Pool, "when loading the pool configuration from a Hash" do
32
+
33
+ let(:config) do
34
+ {
35
+ 'foo' => 8,
36
+ 'test' => { 'bar' => 10, 'foo,bar' => 12 },
37
+ 'development' => { 'baz' => 14, 'foo,bar' => 16 },
38
+ }
39
+ end
40
+
41
+ subject { Qless::Pool.new(config) }
42
+
43
+ context "when RAILS_ENV is set" do
44
+ before { RAILS_ENV = "test" }
45
+
46
+ it "should load the default values from the Hash" do
47
+ subject.config["foo"].should == 8
48
+ end
49
+
50
+ it "should merge the values for the correct RAILS_ENV" do
51
+ subject.config["bar"].should == 10
52
+ subject.config["foo,bar"].should == 12
53
+ end
54
+
55
+ it "should not load the values for the other environments" do
56
+ subject.config["foo,bar"].should == 12
57
+ subject.config["baz"].should be_nil
58
+ end
59
+
60
+ end
61
+
62
+ context "when Rails.env is set" do
63
+ before(:each) do
64
+ module Rails; end
65
+ Rails.stub(:env).and_return('test')
66
+ end
67
+
68
+ it "should load the default values from the Hash" do
69
+ subject.config["foo"].should == 8
70
+ end
71
+
72
+ it "should merge the values for the correct RAILS_ENV" do
73
+ subject.config["bar"].should == 10
74
+ subject.config["foo,bar"].should == 12
75
+ end
76
+
77
+ it "should not load the values for the other environments" do
78
+ subject.config["foo,bar"].should == 12
79
+ subject.config["baz"].should be_nil
80
+ end
81
+
82
+ after(:all) { Object.send(:remove_const, :Rails) }
83
+ end
84
+
85
+
86
+ context "when ENV['QLESS_ENV'] is set" do
87
+ before { ENV['QLESS_ENV'] = 'development' }
88
+ it "should load the config for that environment" do
89
+ subject.config["foo"].should == 8
90
+ subject.config["foo,bar"].should == 16
91
+ subject.config["baz"].should == 14
92
+ subject.config["bar"].should be_nil
93
+ end
94
+ end
95
+
96
+ context "when there is no environment" do
97
+ it "should load the default values only" do
98
+ subject.config["foo"].should == 8
99
+ subject.config["bar"].should be_nil
100
+ subject.config["foo,bar"].should be_nil
101
+ subject.config["baz"].should be_nil
102
+ end
103
+ end
104
+
105
+ end
106
+
107
+ describe Qless::Pool, "given no configuration" do
108
+ subject { Qless::Pool.new(nil) }
109
+ it "should have no worker types" do
110
+ subject.config.should == {}
111
+ end
112
+ end
113
+
114
+ describe Qless::Pool, "when loading the pool configuration from a file" do
115
+
116
+ subject { Qless::Pool.new("spec/qless-pool.yml") }
117
+
118
+ context "when RAILS_ENV is set" do
119
+ before { RAILS_ENV = "test" }
120
+
121
+ it "should load the default YAML" do
122
+ subject.config["foo"].should == 1
123
+ end
124
+
125
+ it "should merge the YAML for the correct RAILS_ENV" do
126
+ subject.config["bar"].should == 5
127
+ subject.config["foo,bar"].should == 3
128
+ end
129
+
130
+ it "should not load the YAML for the other environments" do
131
+ subject.config["foo"].should == 1
132
+ subject.config["bar"].should == 5
133
+ subject.config["foo,bar"].should == 3
134
+ subject.config["baz"].should be_nil
135
+ end
136
+
137
+ end
138
+
139
+ context "when ENV['RACK_ENV'] is set" do
140
+ before { ENV['RACK_ENV'] = 'development' }
141
+ it "should load the config for that environment" do
142
+ subject.config["foo"].should == 1
143
+ subject.config["foo,bar"].should == 4
144
+ subject.config["baz"].should == 23
145
+ subject.config["bar"].should be_nil
146
+ end
147
+ end
148
+
149
+ context "when there is no environment" do
150
+ it "should load the default values only" do
151
+ subject.config["foo"].should == 1
152
+ subject.config["bar"].should be_nil
153
+ subject.config["foo,bar"].should be_nil
154
+ subject.config["baz"].should be_nil
155
+ end
156
+ end
157
+
158
+ context "when a custom file is specified" do
159
+ before { ENV["QLESS_POOL_CONFIG"] = 'spec/qless-pool-custom.yml.erb' }
160
+ subject { Qless::Pool.new(Qless::Pool.choose_config_file) }
161
+ it "should find the right file, and parse the ERB" do
162
+ subject.config["foo"].should == 2
163
+ end
164
+ end
165
+
166
+ end
@@ -0,0 +1,3 @@
1
+ require 'rspec'
2
+ $LOAD_PATH << File.expand_path("../lib", File.dirname(__FILE__))
3
+ require 'qless/pool'
metadata ADDED
@@ -0,0 +1,213 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: qless-pool
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Matt Conway
9
+ - Nicholas a. Evans
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2013-06-28 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: qless
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.9.2
22
+ none: false
23
+ prerelease: false
24
+ type: :runtime
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.9.2
30
+ none: false
31
+ - !ruby/object:Gem::Dependency
32
+ name: trollop
33
+ requirement: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '1.16'
38
+ none: false
39
+ prerelease: false
40
+ type: :runtime
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '1.16'
46
+ none: false
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ none: false
55
+ prerelease: false
56
+ type: :runtime
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ none: false
63
+ - !ruby/object:Gem::Dependency
64
+ name: rspec
65
+ requirement: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 2.10.0
70
+ none: false
71
+ prerelease: false
72
+ type: :development
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 2.10.0
78
+ none: false
79
+ - !ruby/object:Gem::Dependency
80
+ name: cucumber
81
+ requirement: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: 1.2.0
86
+ none: false
87
+ prerelease: false
88
+ type: :development
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 1.2.0
94
+ none: false
95
+ - !ruby/object:Gem::Dependency
96
+ name: aruba
97
+ requirement: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: 0.4.11
102
+ none: false
103
+ prerelease: false
104
+ type: :development
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 0.4.11
110
+ none: false
111
+ - !ruby/object:Gem::Dependency
112
+ name: bundler
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: '1.0'
118
+ none: false
119
+ prerelease: false
120
+ type: :development
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: '1.0'
126
+ none: false
127
+ - !ruby/object:Gem::Dependency
128
+ name: ronn
129
+ requirement: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ none: false
135
+ prerelease: false
136
+ type: :development
137
+ version_requirements: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ none: false
143
+ description: ! " quickly and easily fork a pool of qless workers,\n saving memory
144
+ (w/REE) and monitoring their uptime\n"
145
+ email:
146
+ - matt@conwaysplace.com
147
+ - nick@ekenosen.net
148
+ executables:
149
+ - qless-pool
150
+ extensions: []
151
+ extra_rdoc_files: []
152
+ files:
153
+ - README.md
154
+ - Rakefile
155
+ - LICENSE.txt
156
+ - Changelog.md
157
+ - lib/qless/pool/cli.rb
158
+ - lib/qless/pool/logging.rb
159
+ - lib/qless/pool/pool_factory.rb
160
+ - lib/qless/pool/pooled_worker.rb
161
+ - lib/qless/pool/tasks.rb
162
+ - lib/qless/pool/version.rb
163
+ - lib/qless/pool.rb
164
+ - bin/qless-pool
165
+ - man/qless-pool.1
166
+ - man/qless-pool.1.ronn
167
+ - man/qless-pool.yml.5
168
+ - man/qless-pool.yml.5.ronn
169
+ - features/basic_daemon_config.feature
170
+ - features/step_definitions/daemon_steps.rb
171
+ - features/step_definitions/qless-pool_steps.rb
172
+ - features/support/aruba_daemon_support.rb
173
+ - features/support/env.rb
174
+ - spec/mock_config.rb
175
+ - spec/qless-pool-custom.yml.erb
176
+ - spec/qless-pool.yml
177
+ - spec/qless_pool_spec.rb
178
+ - spec/spec_helper.rb
179
+ homepage: http://github.com/backupify/qless-pool
180
+ licenses: []
181
+ post_install_message:
182
+ rdoc_options: []
183
+ require_paths:
184
+ - lib
185
+ required_ruby_version: !ruby/object:Gem::Requirement
186
+ requirements:
187
+ - - ! '>='
188
+ - !ruby/object:Gem::Version
189
+ version: '0'
190
+ none: false
191
+ required_rubygems_version: !ruby/object:Gem::Requirement
192
+ requirements:
193
+ - - ! '>='
194
+ - !ruby/object:Gem::Version
195
+ version: '0'
196
+ none: false
197
+ requirements: []
198
+ rubyforge_project:
199
+ rubygems_version: 1.8.25
200
+ signing_key:
201
+ specification_version: 3
202
+ summary: quickly and easily fork a pool of qless workers
203
+ test_files:
204
+ - spec/mock_config.rb
205
+ - spec/qless_pool_spec.rb
206
+ - spec/spec_helper.rb
207
+ - spec/qless-pool.yml
208
+ - features/step_definitions/daemon_steps.rb
209
+ - features/step_definitions/qless-pool_steps.rb
210
+ - features/support/aruba_daemon_support.rb
211
+ - features/support/env.rb
212
+ - features/basic_daemon_config.feature
213
+ has_rdoc: