timberline 0.4.0 → 0.4.1
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.
- checksums.yaml +4 -4
- data/README.markdown +1 -1
- data/Rakefile +1 -1
- data/bin/timberline +4 -4
- data/lib/timberline/config.rb +1 -1
- data/lib/timberline/envelope.rb +1 -1
- data/lib/timberline/queue.rb +15 -2
- data/lib/timberline/version.rb +1 -1
- data/lib/timberline.rb +1 -1
- data/spec/support/fake_rails.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b3f445273cef8a33fd4137ad6cffdb91c5af8f5
|
4
|
+
data.tar.gz: 049bab1a641c24643642554ee8f1c89e4fd9c78c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb803ba88627fffc8e1af3ec9253733b584601397fd08d3701e02ace865a0887c9ac0219da754ff4539d0798f923f9c653db8d28e1711b94371f0ffb437b6bdc
|
7
|
+
data.tar.gz: 9d17830ab88a54d2bdde1fe6f0ea02fad125570bf36a9b03bb7aebde17c75a23e21b371df967cb010912a5769eaa66524cd405e22b20b938e8a1ba91799dd6b0
|
data/README.markdown
CHANGED
@@ -101,7 +101,7 @@ queue (more on that later). There are 3 ways to configure Timberline:
|
|
101
101
|
To push a job onto the queue you'll want to make use of the `Timberline#push`
|
102
102
|
method, like so:
|
103
103
|
|
104
|
-
Timberline.push "queue_name", data, { :
|
104
|
+
Timberline.push "queue_name", data, { other_data: some_stuff }
|
105
105
|
|
106
106
|
`queue_name` is the name of the queue you want to push data onto; data is the
|
107
107
|
data you want to push onto the queue (remember that this all gets converted to
|
data/Rakefile
CHANGED
data/bin/timberline
CHANGED
@@ -15,10 +15,10 @@ Usage:
|
|
15
15
|
where [options] are:
|
16
16
|
EOS
|
17
17
|
|
18
|
-
opt :daemonize, "Run the queue listener as a daemon", :
|
19
|
-
opt :log_output, "log the output to <filename>.output (only applicable in conjunction with the daemonize option)", :
|
18
|
+
opt :daemonize, "Run the queue listener as a daemon", default: false
|
19
|
+
opt :log_output, "log the output to <filename>.output (only applicable in conjunction with the daemonize option)", default: false
|
20
20
|
opt :config, "YAML config file to set up Timberline options",
|
21
|
-
:
|
21
|
+
type: String, default: nil
|
22
22
|
end
|
23
23
|
|
24
24
|
unless opts[:config].nil?
|
@@ -30,7 +30,7 @@ timberline_spec = File.read(timberline_file)
|
|
30
30
|
|
31
31
|
if opts[:daemonize]
|
32
32
|
puts "Entering daemon mode"
|
33
|
-
Daemons.daemonize({ :
|
33
|
+
Daemons.daemonize({ app_name: timberline_file, log_output: opts[:log_output] })
|
34
34
|
end
|
35
35
|
|
36
36
|
puts "Listening..."
|
data/lib/timberline/config.rb
CHANGED
@@ -28,7 +28,7 @@ class Timberline
|
|
28
28
|
def redis_config
|
29
29
|
config = {}
|
30
30
|
|
31
|
-
{ :
|
31
|
+
{ db: database, host: host, port: port, timeout: timeout, password: password, logger: logger }.each do |name, value|
|
32
32
|
config[name] = value unless value.nil?
|
33
33
|
end
|
34
34
|
|
data/lib/timberline/envelope.rb
CHANGED
data/lib/timberline/queue.rb
CHANGED
@@ -75,8 +75,21 @@ class Timberline
|
|
75
75
|
|
76
76
|
def average_execution_time
|
77
77
|
successes = Timberline.redis.xmembers(attr("success_stats")).map { |item| Envelope.from_json(item)}
|
78
|
-
times = successes.map
|
79
|
-
|
78
|
+
times = successes.map do |item|
|
79
|
+
if item.finished_processing_at
|
80
|
+
item.finished_processing_at.to_f - item.started_processing_at.to_f
|
81
|
+
elsif item.fatal_error_at
|
82
|
+
item.fatal_error_at.to_f - item.started_processing_at.to_f
|
83
|
+
else
|
84
|
+
nil
|
85
|
+
end
|
86
|
+
end
|
87
|
+
times.reject! { |t| t.nil? }
|
88
|
+
if times.size == 0
|
89
|
+
0
|
90
|
+
else
|
91
|
+
times.inject(0, :+) / times.size.to_f
|
92
|
+
end
|
80
93
|
end
|
81
94
|
|
82
95
|
def add_retry_stat(item)
|
data/lib/timberline/version.rb
CHANGED
data/lib/timberline.rb
CHANGED
@@ -20,7 +20,7 @@ class Timberline
|
|
20
20
|
def self.redis=(server)
|
21
21
|
initialize_if_necessary
|
22
22
|
if server.is_a? Redis
|
23
|
-
@redis = Redis::Namespace.new(@config.namespace, :
|
23
|
+
@redis = Redis::Namespace.new(@config.namespace, redis: server)
|
24
24
|
elsif server.is_a? Redis::Namespace
|
25
25
|
@redis = server
|
26
26
|
elsif server.nil?
|
data/spec/support/fake_rails.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
module SpecSupport
|
2
2
|
module FakeRails
|
3
3
|
def self.create_fake_env
|
4
|
-
fake_rails = OpenStruct.new(:
|
4
|
+
fake_rails = OpenStruct.new(root: File.join(File.dirname(File.path(__FILE__)), "..", "fake_rails"), env: "development")
|
5
5
|
Object.send(:const_set, :Rails, fake_rails)
|
6
6
|
end
|
7
7
|
|
8
8
|
def self.create_fake_env_without_config
|
9
|
-
fake_rails = OpenStruct.new(:
|
9
|
+
fake_rails = OpenStruct.new(root: File.join(File.dirname(File.path(__FILE__)), "..", "gibberish"), env: "development")
|
10
10
|
Object.send(:const_set, :Rails, fake_rails)
|
11
11
|
end
|
12
12
|
|