timberline 0.8.5 → 0.8.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6f3dfd9c720cbfdd13437a4f993314cc6bd1efd0
4
- data.tar.gz: 711690699ad0b93354396aacb8d550d41759513e
3
+ metadata.gz: e1b6a21eb5632e2c1c6aa2bf9a5b10b959845257
4
+ data.tar.gz: ef713d037a79f52d7ab59bd00c883ba5ffeb1566
5
5
  SHA512:
6
- metadata.gz: 9864cd6bd4aef55a8871f1e3cf7103c7ab42e8ec0e75552e3097a625852717f1f132a07477ff1c0ff522a05b83133e04d27dcfc576e3b3fc7a92f4f770f3077f
7
- data.tar.gz: b3c073f280198da05af738b1a94d37187231e11795f534b5abfdb695a2b774fc40b601b89f1fd8b94fbc20caf14a237d09a728799cb067c7a6b727543847211e
6
+ metadata.gz: 67996b724ec828c41b5a44c179b55899bf646c8d0ef5f6f3928514e4968c0fed7eb0282016acc4c7ab0340381f0a731f74fcb007581a99c3d1d6e62d08dacd8c
7
+ data.tar.gz: e56e9d483a53122a8cfb572bd0d6b8d07c1262d167d68de37d9061f9d2ef137af66344ce97391b22aff0d3b1cbc1fcd63dfb3d01bc3b94f28a888a82937c8703
@@ -1,10 +1,9 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.3
3
+ - 2.2.0
4
+ - 2.5.0
4
5
  - jruby-19mode
5
6
  - jruby-head
6
- - 2.0.0
7
- - 2.1.0
8
7
  - ruby-head
9
8
  services:
10
9
  - redis-server
data/CHANGELOG CHANGED
@@ -1,3 +1,6 @@
1
+ 0.8.6
2
+ - Turned off job stat logging by default (configure with log_job_result_stats config property)
3
+ - Updated outdated redis api
1
4
  0.8.4
2
5
  - Allow stat_timeout and max_retries to be set from config
3
6
  0.8.3
@@ -141,6 +141,13 @@ class Timberline
141
141
  @config.stat_timeout * 60
142
142
  end
143
143
 
144
+ # Lazy-loads the Timberline configuration.
145
+ # @return [Boolean] whether we want to record result stats for each job in a redis queue
146
+ def self.log_job_results?
147
+ initialize_if_necessary
148
+ @config.log_job_result_stats
149
+ end
150
+
144
151
  # Create and start a new AnonymousWorker with the given
145
152
  # queue_name and block. Convenience method.
146
153
  #
@@ -27,7 +27,7 @@ class Timberline
27
27
  # for failover protection.
28
28
  #
29
29
  class Config
30
- attr_accessor :database, :host, :port, :timeout, :password,
30
+ attr_accessor :database, :host, :port, :timeout, :password, :log_job_result_stats,
31
31
  :logger, :namespace, :max_retries, :stat_timeout, :sentinels
32
32
 
33
33
  # Attemps to load configuration from TIMBERLINE_YAML, if it exists.
@@ -52,6 +52,12 @@ class Timberline
52
52
  @stat_timeout ||= 60
53
53
  end
54
54
 
55
+ # @return [Boolean] configuration setting for logging each job success or error in redis
56
+ # created in response to max memory limit on redis queues in aws
57
+ def log_job_result_stats
58
+ @log_job_result_stats ||= false
59
+ end
60
+
55
61
  # @return [{host: "x", port: 1}] list of sentinel server
56
62
  def sentinels
57
63
  @sentinels ||= []
@@ -93,6 +99,11 @@ class Timberline
93
99
  val.match(/\A[+-]?\d+\Z/) ? val.to_i : val
94
100
  end
95
101
 
102
+ def convert_if_bool(val)
103
+ # convert potential string respresentations of boolean values to ruby booleans
104
+ val.to_s.strip.downcase == "true"
105
+ end
106
+
96
107
  def configure_via_env
97
108
  return unless ENV.key?("TIMBERLINE_URL")
98
109
 
@@ -105,6 +116,10 @@ class Timberline
105
116
  @password = uri.password
106
117
 
107
118
  params = uri.query.nil? ? {} : CGI.parse(uri.query)
119
+ %w(log_job_result_stats).each do |setting|
120
+ next unless params.key?(setting)
121
+ instance_variable_set("@#{setting}", convert_if_bool(params[setting][0]))
122
+ end
108
123
  %w(timeout namespace stat_timeout max_retries).each do |setting|
109
124
  next unless params.key?(setting)
110
125
  instance_variable_set("@#{setting}", convert_if_int(params[setting][0]))
@@ -119,7 +134,7 @@ class Timberline
119
134
 
120
135
  def load_from_yaml(yaml_config)
121
136
  fail "Missing yaml configs!" if yaml_config.nil?
122
- %w(database host port timeout password namespace sentinels stat_timeout max_retries).each do |setting|
137
+ %w(database host port timeout password namespace sentinels stat_timeout max_retries log_job_result_stats).each do |setting|
123
138
  instance_variable_set("@#{setting}", yaml_config[setting])
124
139
  end
125
140
  end
@@ -99,21 +99,21 @@ class Timberline
99
99
  # @see Timberline::Queue#pop
100
100
  #
101
101
  def pause
102
- @redis[attr("paused")] = "true"
102
+ @redis.set(attr("paused"), "true")
103
103
  end
104
104
 
105
105
  # Takes this queue back out of paused mode.
106
106
  # @see Timberline::Queue#pop
107
107
  #
108
108
  def unpause
109
- @redis[attr("paused")] = "false"
109
+ @redis.set(attr("paused"), "false")
110
110
  end
111
111
 
112
112
  # Indicates whether or not this queue is currently in paused mode.
113
113
  # @return [boolean]
114
114
  #
115
115
  def paused?
116
- @redis[attr("paused")] == "true"
116
+ @redis.get(attr("paused")) == "true"
117
117
  end
118
118
 
119
119
  # Given a key, create a string namespaced to this queue name.
@@ -249,6 +249,7 @@ class Timberline
249
249
  private
250
250
 
251
251
  def add_stat_for_key(key, item)
252
+ return unless Timberline.log_job_results?
252
253
  Timberline.redis.xadd key, item, Time.now + Timberline.stat_timeout_seconds
253
254
  end
254
255
 
@@ -1,4 +1,4 @@
1
1
  class Timberline
2
2
  # The current canonical version for Timberline.
3
- VERSION = "0.8.5"
3
+ VERSION = "0.8.6"
4
4
  end
@@ -38,11 +38,11 @@ describe Timberline::Queue do
38
38
  end
39
39
 
40
40
  it "removes the queue from redis" do
41
- expect(Timberline.redis["fritters"]).to be_nil
41
+ expect(Timberline.redis.get("fritters")).to be_nil
42
42
  end
43
43
 
44
44
  it "removes all of the queue's attributes from redis" do
45
- expect(Timberline.redis["fritters:*"]).to be_nil
45
+ expect(Timberline.redis.get("fritters:*")).to be_nil
46
46
  end
47
47
 
48
48
  it "removes the queue from the Timberline queue listing" do
@@ -113,6 +113,9 @@ describe Timberline::Queue do
113
113
  let(:item) { subject.push("apple"); subject.pop }
114
114
 
115
115
  before do
116
+ Timberline.configure do |c|
117
+ c.log_job_result_stats = true
118
+ end
116
119
  subject.error_item(item)
117
120
  end
118
121
 
@@ -135,6 +138,9 @@ describe Timberline::Queue do
135
138
 
136
139
  context "when the item hasn't been retried before" do
137
140
  before do
141
+ Timberline.configure do |c|
142
+ c.log_job_result_stats = true
143
+ end
138
144
  subject.retry_item(item)
139
145
  end
140
146
 
@@ -153,6 +159,9 @@ describe Timberline::Queue do
153
159
 
154
160
  context "when the item has been retried before" do
155
161
  before do
162
+ Timberline.configure do |c|
163
+ c.log_job_result_stats = true
164
+ end
156
165
  item.retries = 3
157
166
  subject.retry_item(item)
158
167
  end
@@ -181,4 +190,64 @@ describe Timberline::Queue do
181
190
  end
182
191
  end
183
192
  end
193
+
194
+ describe "#add_--_stat" do
195
+
196
+ context "error stat logging" do
197
+
198
+ subject { Timberline::Queue.new("popovers") }
199
+ let(:item) { subject.push("butter"); subject.pop }
200
+
201
+ it "doesn't log an error if log_job_result_stats is set to false (default setting)" do
202
+ subject.add_error_stat(item)
203
+ expect(subject.number_errors).to eq(0)
204
+ end
205
+
206
+ it "logs an error if log_job_result_stats is set to true" do
207
+ Timberline.configure do |c|
208
+ c.log_job_result_stats = true
209
+ end
210
+ subject.add_error_stat(item)
211
+ expect(subject.number_errors).to eq(1)
212
+ end
213
+ end
214
+
215
+ context "success stat logging" do
216
+
217
+ subject { Timberline::Queue.new("dutch_oven") }
218
+ let(:item) { subject.push("strawberry_jam"); subject.pop }
219
+
220
+ it "doesn't log a success if log_job_result_stats is set to false (default setting)" do
221
+ subject.add_success_stat(item)
222
+ expect(subject.number_successes).to eq(0)
223
+ end
224
+
225
+ it "logs a success if log_job_result_stats is set to true" do
226
+ Timberline.configure do |c|
227
+ c.log_job_result_stats = true
228
+ end
229
+ subject.add_success_stat(item)
230
+ expect(subject.number_successes).to eq(1)
231
+ end
232
+ end
233
+
234
+ context "retry stat logging" do
235
+
236
+ subject { Timberline::Queue.new("pancakes") }
237
+ let(:item) { subject.push("blueberry"); subject.pop }
238
+
239
+ it "doesn't log a retry attempt if log_job_result_stats is set to false (default setting)" do
240
+ subject.add_retry_stat(item)
241
+ expect(subject.number_retries).to eq(0)
242
+ end
243
+
244
+ it "logs a retry attempt if log_job_result_stats is set to true" do
245
+ Timberline.configure do |c|
246
+ c.log_job_result_stats = true
247
+ end
248
+ subject.add_retry_stat(item)
249
+ expect(subject.number_retries).to eq(1)
250
+ end
251
+ end
252
+ end
184
253
  end
@@ -26,6 +26,6 @@ Gem::Specification.new do |s|
26
26
 
27
27
  s.add_development_dependency "yard"
28
28
  s.add_development_dependency "rake"
29
- s.add_development_dependency "rspec", '~> 3.0.0.rc1'
29
+ s.add_development_dependency "rspec", '~> 3.5'
30
30
  s.add_development_dependency "pry"
31
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timberline
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.5
4
+ version: 0.8.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tommy Morgan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-22 00:00:00.000000000 Z
11
+ date: 2018-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -114,14 +114,14 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 3.0.0.rc1
117
+ version: '3.5'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 3.0.0.rc1
124
+ version: '3.5'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: pry
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -197,7 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
197
197
  version: '0'
198
198
  requirements: []
199
199
  rubyforge_project: timberline
200
- rubygems_version: 2.2.3
200
+ rubygems_version: 2.5.2.3
201
201
  signing_key:
202
202
  specification_version: 4
203
203
  summary: Timberline is a simple and extensible queuing system built in Ruby and backed
@@ -212,4 +212,3 @@ test_files:
212
212
  - spec/spec_helper.rb
213
213
  - spec/support/timberline_reset.rb
214
214
  - spec/support/timberline_yaml.rb
215
- has_rdoc: