refinery 0.9.4 → 0.9.5
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/refinery/daemon.rb +8 -3
- data/lib/refinery/server.rb +1 -1
- data/refinery.gemspec +2 -2
- data/test/unit/daemon_test.rb +4 -0
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.9.
|
1
|
+
0.9.5
|
data/lib/refinery/daemon.rb
CHANGED
@@ -47,7 +47,12 @@ module Refinery #:nodoc:
|
|
47
47
|
# * <tt>waiting_queue</tt>: The waiting queue that provides messages to be processed
|
48
48
|
# * <tt>error_queue</tt>: The queue where errors are posted.
|
49
49
|
# * <tt>done_queue</tt>: The queue for messages that have been processed.
|
50
|
-
|
50
|
+
# * <tt>settings</tt>: The settings hash from the config.
|
51
|
+
#
|
52
|
+
# The settings hash may contain the following options:
|
53
|
+
# * <tt>visibility</tt>: The time in seconds that the message is hidden
|
54
|
+
# in the queue.
|
55
|
+
def initialize(server, name, waiting_queue, error_queue, done_queue, settings={})
|
51
56
|
Refinery::Server.logger.debug "Starting daemon"
|
52
57
|
|
53
58
|
@server = server
|
@@ -57,10 +62,10 @@ module Refinery #:nodoc:
|
|
57
62
|
@done_queue = done_queue
|
58
63
|
|
59
64
|
@thread = Thread.new(self) do |daemon|
|
60
|
-
logger.debug "Running daemon thread"
|
65
|
+
logger.debug "Running daemon thread: #{name} (settings: #{settings.inspect})"
|
61
66
|
while(running?)
|
62
67
|
begin
|
63
|
-
while (message = waiting_queue.receive)
|
68
|
+
while (message = waiting_queue.receive(settings['visibility']))
|
64
69
|
worker = load_worker_class(name).new(self)
|
65
70
|
begin
|
66
71
|
result, run_time = worker.run(decode_message(message.body))
|
data/lib/refinery/server.rb
CHANGED
@@ -71,7 +71,7 @@ module Refinery #:nodoc:
|
|
71
71
|
done_queue = queue("#{queue_name}_done")
|
72
72
|
|
73
73
|
1.upto(settings['workers']['initial']) do
|
74
|
-
daemons << Refinery::Daemon.new(self, key, waiting_queue, error_queue, done_queue)
|
74
|
+
daemons << Refinery::Daemon.new(self, key, waiting_queue, error_queue, done_queue, settings)
|
75
75
|
end
|
76
76
|
|
77
77
|
logger.debug "Running #{daemons.length} daemons"
|
data/refinery.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{refinery}
|
5
|
-
s.version = "0.9.
|
5
|
+
s.version = "0.9.5"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Anthony Eden"]
|
9
|
-
s.date = %q{2009-
|
9
|
+
s.date = %q{2009-07-02}
|
10
10
|
s.description = %q{Process data in a distributed fashion.}
|
11
11
|
s.email = %q{anthonyeden@gmail.com}
|
12
12
|
s.executables = ["epub", "monitor", "pubnow", "refinery"]
|
data/test/unit/daemon_test.rb
CHANGED
@@ -17,6 +17,10 @@ class DaemonTest < Test::Unit::TestCase
|
|
17
17
|
daemon = Refinery::Daemon.new(@server, 'sample', @waiting_queue, @error_queue, @done_queue)
|
18
18
|
assert_not_nil daemon.logger
|
19
19
|
end
|
20
|
+
should "allow visibility setting" do
|
21
|
+
@waiting_queue.stubs(:receive).with({'visibility' => 600})
|
22
|
+
daemon = Refinery::Daemon.new(@server, 'sample', @waiting_queue, @error_queue, @done_queue, {'visibility' => 600})
|
23
|
+
end
|
20
24
|
context "that is started" do
|
21
25
|
setup do
|
22
26
|
@daemon = Refinery::Daemon.new(@server, 'sample', @waiting_queue, @error_queue, @done_queue)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: refinery
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anthony Eden
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-07-02 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|