micro_q 0.8.0 → 0.9.0
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/.travis.yml +2 -0
- data/README.md +5 -3
- data/lib/micro_q/dsl.rb +5 -5
- data/lib/micro_q/version.rb +1 -1
- data/spec/lib/dsl_spec.rb +11 -11
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 594090928b9d6ed47e533456305b1944bb76d593
|
4
|
+
data.tar.gz: 76195292f3ea53b5d0b0ceb80033cac71e9e52a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6443272fd150e6ca1e1a022445bd22a462856af5db981b86a207e4665d599d58727125198ccb4ca77ae1077b1f2d225bf4c2f5baacad449894d1bb1491762c2
|
7
|
+
data.tar.gz: 60c5ffda9d6cf7423ef0a86c6ba6fa012347cc1131db87260855e410f7c4336c09f4d109a817f178ded2b07c70805aaccc60fa02e3f25fa1f55cdc8c797dcd05
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -24,7 +24,7 @@ Or install it:
|
|
24
24
|
```ruby
|
25
25
|
## A typical worker class
|
26
26
|
class MyWorker
|
27
|
-
worker :update # sets up the dsl and adds additional
|
27
|
+
worker :update # sets up the dsl and adds additional _async methods
|
28
28
|
|
29
29
|
def perform
|
30
30
|
# do some performing here
|
@@ -39,8 +39,10 @@ end
|
|
39
39
|
###Simple
|
40
40
|
|
41
41
|
```ruby
|
42
|
-
|
43
|
-
|
42
|
+
Called on the class invoked on an instance.
|
43
|
+
|
44
|
+
MyWorker.perform_async
|
45
|
+
MyWorker.update_async(:user_id => user.id)
|
44
46
|
```
|
45
47
|
|
46
48
|
###Advanced
|
data/lib/micro_q/dsl.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module MicroQ
|
2
2
|
##
|
3
3
|
# Convenience methods for calling methods asynchronously
|
4
|
-
# Adds
|
4
|
+
# Adds perform_async by default
|
5
5
|
#
|
6
6
|
# Usage
|
7
7
|
# class MyWorker
|
@@ -11,23 +11,23 @@ module MicroQ
|
|
11
11
|
# end
|
12
12
|
# end
|
13
13
|
#
|
14
|
-
# MyWorker.
|
14
|
+
# MyWorker.update_async
|
15
15
|
# is the same as
|
16
16
|
# MyWorker.new.async(:queue => 'non-default').update
|
17
17
|
#
|
18
18
|
module DSL
|
19
19
|
##
|
20
20
|
# For each of the methods given to the Object.worker method
|
21
|
-
# define the
|
21
|
+
# define the _async post-fixed version for convenience
|
22
22
|
#
|
23
23
|
def self.attach_async_methods(target, opts)
|
24
24
|
target.class_eval do
|
25
25
|
(target.microq_options[:methods] |= opts.flatten).each do |method|
|
26
|
-
target.define_singleton_method(:"
|
26
|
+
target.define_singleton_method(:"#{method}_async") do |*args|
|
27
27
|
MicroQ::Proxy::Instance.new(
|
28
28
|
target.microq_options.dup.merge(:class => self)
|
29
29
|
).send(method, *args)
|
30
|
-
end unless respond_to?(:"
|
30
|
+
end unless respond_to?(:"#{method}_async")
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
data/lib/micro_q/version.rb
CHANGED
data/spec/lib/dsl_spec.rb
CHANGED
@@ -14,16 +14,16 @@ describe MicroQ::DSL do
|
|
14
14
|
Object.should be_is_a(MicroQ::DSL::ClassMethods)
|
15
15
|
end
|
16
16
|
|
17
|
-
it 'should add the
|
18
|
-
OtherWorker.should be_respond_to(:
|
17
|
+
it 'should add the perform_async method' do
|
18
|
+
OtherWorker.should be_respond_to(:perform_async)
|
19
19
|
end
|
20
20
|
|
21
|
-
it 'should add
|
22
|
-
OtherWorker.should be_respond_to(:
|
21
|
+
it 'should add _async post-fixed method when given them' do
|
22
|
+
OtherWorker.should be_respond_to(:update_async)
|
23
23
|
end
|
24
24
|
|
25
|
-
describe 'when calling the
|
26
|
-
let(:method) { ->(*args) { OtherWorker.
|
25
|
+
describe 'when calling the _async method' do
|
26
|
+
let(:method) { ->(*args) { OtherWorker.perform_async(*args) } }
|
27
27
|
|
28
28
|
before do
|
29
29
|
@proxy = mock(MicroQ::Proxy::Instance, :perform => nil)
|
@@ -61,8 +61,8 @@ describe MicroQ::DSL do
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
-
describe 'when calling the
|
65
|
-
let(:method) { ->(*args) { OtherWorker.
|
64
|
+
describe 'when calling the something_async method' do
|
65
|
+
let(:method) { ->(*args) { OtherWorker.update_async(*args) } }
|
66
66
|
|
67
67
|
before do
|
68
68
|
@proxy = mock(MicroQ::Proxy::Instance, :update => nil)
|
@@ -101,9 +101,9 @@ describe MicroQ::DSL do
|
|
101
101
|
worker :other_method, :queue => 'my-queue', :option => 'value'
|
102
102
|
end
|
103
103
|
|
104
|
-
it 'should have the
|
105
|
-
OptionWorker.should be_respond_to(:
|
106
|
-
OptionWorker.should be_respond_to(:
|
104
|
+
it 'should have the _async methods' do
|
105
|
+
OptionWorker.should be_respond_to(:method_name_async)
|
106
|
+
OptionWorker.should be_respond_to(:other_method_async)
|
107
107
|
end
|
108
108
|
|
109
109
|
it 'should store the options' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: micro_q
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Norton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-03-
|
11
|
+
date: 2013-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: celluloid
|