orionz-minion 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +12 -1
- data/VERSION +1 -1
- data/examples/when.rb +25 -0
- metadata +5 -3
data/README.rdoc
CHANGED
@@ -63,13 +63,24 @@ queues when you enqueue.
|
|
63
63
|
puts "I have #{args["type"]} sandwich for #{args["me"]}"
|
64
64
|
end
|
65
65
|
|
66
|
+
== Conditional Processing
|
67
|
+
|
68
|
+
If you want a minion worker to only subscribe to a queue under specific
|
69
|
+
conditions there is a :when parameter that takes a lambda as an argument. For
|
70
|
+
example, if you had a queue that makes sandwiches but only if there is bread
|
71
|
+
on hand, it would be.
|
72
|
+
|
73
|
+
job "make.sandwich", :when => lambda { not Bread.out? } do
|
74
|
+
Sandwich.make
|
75
|
+
end
|
76
|
+
|
66
77
|
== Error handling
|
67
78
|
|
68
79
|
When an error is thrown in a job handler, the job is requeued to be done later
|
69
80
|
and the minion process exits. If you define an error handler, however, the
|
70
81
|
error handler is run and the job is removed from the queue.
|
71
82
|
|
72
|
-
|
83
|
+
error do |e|
|
73
84
|
puts "got an error! #{e}"
|
74
85
|
end
|
75
86
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.4
|
data/examples/when.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'minion'
|
5
|
+
|
6
|
+
include Minion
|
7
|
+
|
8
|
+
error do |e|
|
9
|
+
puts "got an error!"
|
10
|
+
end
|
11
|
+
|
12
|
+
logger do |msg|
|
13
|
+
puts "--> #{msg}"
|
14
|
+
end
|
15
|
+
|
16
|
+
$listen = true
|
17
|
+
|
18
|
+
job "do.once", :when => lambda { $listen } do |args|
|
19
|
+
puts "Do this one action - then unsubscribe..."
|
20
|
+
$listen = false
|
21
|
+
end
|
22
|
+
|
23
|
+
enqueue("do.once",[])
|
24
|
+
enqueue("do.once",[])
|
25
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: orionz-minion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Orion Henry
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-09-02 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -55,9 +55,10 @@ files:
|
|
55
55
|
- VERSION
|
56
56
|
- examples/math.rb
|
57
57
|
- examples/sandwich.rb
|
58
|
+
- examples/when.rb
|
58
59
|
- lib/minion.rb
|
59
60
|
- lib/minion/handler.rb
|
60
|
-
has_rdoc:
|
61
|
+
has_rdoc: false
|
61
62
|
homepage: http://github.com/orionz/minion
|
62
63
|
licenses:
|
63
64
|
post_install_message:
|
@@ -87,3 +88,4 @@ summary: Super simple job queue over AMQP
|
|
87
88
|
test_files:
|
88
89
|
- examples/math.rb
|
89
90
|
- examples/sandwich.rb
|
91
|
+
- examples/when.rb
|