resque-async 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 82a081a18ff934bada8285c11636890167dabebc
4
- data.tar.gz: ed7c2763ac18fb93febfd05f501603bb0fd831f7
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YmE0NzRhYWZlMmQ4YThhZGQzZDgwY2I4MjU2MThiMGVhNTU0MWVkNg==
5
+ data.tar.gz: !binary |-
6
+ NzVkYjJiOTYyZThlYjBmYWNjMTk5MWZkMDNjNzhmZWYzN2NhY2RiMA==
5
7
  SHA512:
6
- metadata.gz: ced53755853e7c5b82a8fb3586ea2dcc9a2e6ff4da0cc7a87f83a03dc73501344a7bc25034b17cba323a74257f0f056351a44d2b34042e4756acdb10fd8ad4f1
7
- data.tar.gz: 5f1532534f510bd6f11b98f0f141d60a7b320aa9987da58b39c82fa2cddfac04a975f57a087a66dd92d1c06bb02faedae033977603faa090146e58f464baffea
8
+ metadata.gz: !binary |-
9
+ NDdmZjg4ZmEwYmRiZDdmOGQ3NjY0OTBlZGMwYTNlNDZiYjhhMTUyYWZhMzBk
10
+ N2ZhOTMxZTc5ZmQxZWI4MGFkMTg3MjM0MzMyNmYyODUzNDRiZGJjZGU2ZmZi
11
+ MTVjNWI4NzNlMDZmMmVjYzUwZTJhN2M1ODg5OGY1ZmY3OTliNjA=
12
+ data.tar.gz: !binary |-
13
+ YzQwMDMwMmM4NTNlMWIyNTYxM2ZjYjA5YjY4OTcwY2VhYTcyNmEzZTY2NmYz
14
+ MjAwZThiZWYyZjgwZDhkYTlkYzYwYTkxODRhOWEzMGU3NDQwZTRhMjc2NzIw
15
+ ZDg1ZDEyNGEwZTcyMjRkZWIzMGM2MjM1MTYwN2M1NThjNzA5ODU=
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # ResqueAsync
2
2
 
3
3
  A simple way to invoke methods asynchronously using Resque. There are a few gems that provide similar functionality.
4
- However We like the more declarative syntax with this implementation. As it gives the caller control over the invocation
4
+ However this this implementation provides more expressive syntax that it gives the caller control over the invocation.
5
5
 
6
6
  ## Installation
7
7
 
@@ -21,19 +21,43 @@ Or install it yourself as:
21
21
 
22
22
  ## Usage
23
23
 
24
+ Assuming
25
+
26
+ ```ruby
27
+ class MyObject < ActiveRecord::Base
28
+ def self.slow_class_method
29
+ end
30
+ def slow_instance_method
31
+ end
32
+ end
33
+ ```
34
+
24
35
  Supports Class Methods and ActiveRecord instance methods
25
36
 
26
37
  ```ruby
27
38
  MyObject.async(:high).slow_class_method
28
- record_instance.async(:medium).slow_instance_method
39
+
40
+ # ActiveRecord instances will be queued/loaded/invoked asynchronously
41
+ MyObject.new.async(:medium).slow_instance_method
29
42
  ```
30
43
 
31
- Support high, medium, low priority out of the box. As well as custom work/queue
44
+ Natural synchronous invocation
45
+ ```ruby
46
+ MyObject.slow_class_method
47
+ MyObject.new.slow_instance_method
48
+ ```
49
+
50
+ Support high, medium, low priority out of the box. As well as custom worker/queue
32
51
 
33
52
  ```ruby
34
- MyObject.async(:high).high_priority
35
- MyObject.async(:medium).medium_priority
36
- MyObject.async(:low).low_priority
53
+ # slow_class_method queued/invoked on 'high' queue
54
+ MyObject.async(:high).slow_class_method
55
+
56
+ # slow_class_method queued/invoked on 'medium' queue
57
+ MyObject.async(:medium).slow_class_method
58
+
59
+ # slow_class_method queued/invoked on 'low' queue
60
+ MyObject.async(:low).slow_class_method
37
61
  ```
38
62
  OR
39
63
  ```ruby
@@ -44,10 +68,37 @@ end
44
68
  MyObject.async(MyCustomerWorker).crazy_priority
45
69
  ```
46
70
 
71
+ ## What about resque-async-method?
72
+
73
+ [resque-async-method](https://github.com/nragaz/resque-async-method) hides the fact that a method may be invoked asynchronously.
74
+ From the caller's perspective things can get really confusing.
75
+
76
+ With resque-async-method
77
+ ```ruby
78
+ class MyObject < ActiveRecord::Base
79
+ def slow_method
80
+ end
81
+ async_method :slow_method
82
+ end
83
+
84
+ # is this async or not? What does result equal? Better check the implementation of MyObject
85
+ result = MyObject.new.slow_method
86
+ ```
87
+
88
+ With resque-async
89
+ ```ruby
90
+ class MyObject < ActiveRecord::Base
91
+ def slow_method
92
+ end
93
+ end
94
+
95
+ # this should be pretty obvious, even years later, that slow_method is invoked async
96
+ d = MyObject.new.async(:low).slow_method
97
+ ```
47
98
 
48
99
  ## Contributing
49
100
 
50
- 1. Fork it ( https://github.com/[my-github-username]/resque-async/fork )
101
+ 1. Fork it ( https://github.com/exitround/resque-async/fork )
51
102
  2. Create your feature branch (`git checkout -b my-new-feature`)
52
103
  3. Commit your changes (`git commit -am 'Add some feature'`)
53
104
  4. Push to the branch (`git push origin my-new-feature`)
@@ -23,6 +23,8 @@ module ResqueAsync
23
23
  worker = Workers::MediumPriorityClassMethod
24
24
  when :low
25
25
  worker = Workers::LowPriorityClassMethod
26
+ when :realtime
27
+ return args.empty? ? @host_class.send(methId.id2name) : @host_class.send(methId.id2name, *args)
26
28
  else
27
29
  raise StandardError('Unknown priority')
28
30
  end
@@ -1,3 +1,3 @@
1
1
  module ResqueAsync
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque-async
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Dean
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-06 00:00:00.000000000 Z
11
+ date: 2015-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: resque
@@ -128,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
128
  version: '0'
129
129
  requirements: []
130
130
  rubyforge_project:
131
- rubygems_version: 2.0.3
131
+ rubygems_version: 2.1.11
132
132
  signing_key:
133
133
  specification_version: 4
134
134
  summary: Simple way of invoking methods asynchronously using resque.
@@ -142,4 +142,3 @@ test_files:
142
142
  - spec/support/mock_host.rb
143
143
  - spec/support/worker.rb
144
144
  - spec/workers_spec.rb
145
- has_rdoc: