disc 0.0.18 → 0.0.19

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 82dbce68f29a0a69c52cfed7c9845da55866ecd5
4
- data.tar.gz: 36792205da60c1351d38a45ad5e9e2457662324e
3
+ metadata.gz: ef1c9ba1d12dd36f6ebbdcd38d2da62f9d5390f4
4
+ data.tar.gz: 893aa8601a0c096aa356696115c54187336989fb
5
5
  SHA512:
6
- metadata.gz: 41be8dbe4bb699a597d32bcd622f4729df921aca7f8ea880652118b73ef198b4db2b1de2c558ab377469a5fe6e4c9af74b9eed181de821498b764ec8da30c747
7
- data.tar.gz: dd9ceee2be8160ee955bd91871e0721f77b99d24b5fae0a473539a94c67c1e8ea43b0e7c56e8c5f71116c733fd61823e175a5bbf5a4e54c45f6c20c6006a8218
6
+ metadata.gz: a4a3f2476df67bae5fefa2ffccf83e2a006f8dd4aa8f91c9defbe5d1dd3e48d5085c3974912134067bf97e0f8c6e44d9f001dfc5d7929acf86d33c38421882fc
7
+ data.tar.gz: 41afd9edc3fd42ed2469c72095b102f1b463f7ac92a6a66648aa141a867b389c725ac2b6f19b1e9d508c325197531ef5379ceeeba0f6976dde16972d26377627
data/README.md CHANGED
@@ -58,6 +58,29 @@ Disc fills the gap between your Ruby service objects and [antirez](http://antire
58
58
  ```bash
59
59
  $ QUEUES=urgent,default disc -r ./disc_init.rb
60
60
  ```
61
+
62
+ ## Notes about Jobs
63
+
64
+ Jobs are fairly straighforward Ruby classes, internally Disc serializes them to MessagePack so they can be stored in Disque, this has a few implications:
65
+
66
+ * Don't enqueue complex objects! Instead of `user`, enqueue `user.id`!
67
+ * If your job takes multiple arguments, you'll want to pass all those arguments in the first parameter of `#enqueue` as an array.
68
+
69
+ Example:
70
+
71
+ ```ruby
72
+ class ComplexJob
73
+ include Disc::Job
74
+ disc queue: 'urgent'
75
+
76
+ def perform(first_parameter, second_parameter)
77
+ # do things...
78
+ end
79
+ end
80
+
81
+
82
+ ComplexJob.enqueue(['first argument', { second: 'argument' }]
83
+ ```
61
84
 
62
85
  ## Settings
63
86
 
@@ -100,7 +123,7 @@ The error handler function gets the data of the current job as a Hash, that has
100
123
 
101
124
  ## [Optional] Celluloid integration
102
125
 
103
- Disc workers can run just fine on their own, but if you happen to be using
126
+ Disc workers run just fine on their own, but if you happen to be using
104
127
  [Celluloid](https://github.com/celluloid/celluloid) you might want Disc to take
105
128
  advantage of it and spawn multiple worker threads per process, doing this is
106
129
  trivial! Just require Celluloid before your init file:
@@ -113,7 +136,7 @@ Whenever Disc detects that Celluloid is available it will use it to spawn a
113
136
  number of threads equal to the `DISC_CONCURRENCY` environment variable, or 25 by
114
137
  default.
115
138
 
116
- ## Rails and ActiveJob integration
139
+ ## [Optional] Rails and ActiveJob integration
117
140
 
118
141
  You can use Disc easily in Rails without any more hassle, but if you'd like to use it via [ActiveJob](http://edgeguides.rubyonrails.org/active_job_basics.html) you can use the adapter included in this gem.
119
142
 
@@ -139,17 +162,27 @@ class CluJob < ActiveJob::Base
139
162
  end
140
163
  end
141
164
 
165
+ # disc_init.rb
166
+ require ::File.expand_path('../config/environment', __FILE__)
167
+
142
168
  # Wherever you want
143
169
  CluJob.perform_later(a_bunch_of_arguments)
144
170
  ```
145
171
 
146
- As always, make sure your `disc_init.rb` file requires the necessary jobs and you'll be good to go!
172
+ Disc is run in the exact same way, for this example it'd be:
147
173
 
174
+ ```bash
175
+ $ QUEUES=urgent disc -r ./disc_init.rb
176
+ ```
148
177
 
149
178
  ## A note on stability
150
179
 
151
180
  The version of Disque at the time of this writing is `0.0.1`. It is a wonderful project, I know of people running it in production and I expect it will only get better and better with time, but please do not expect Disc to be more production ready than Disque is.
152
181
 
182
+ ## Similar Projects
183
+
184
+ If you want to use Disque but Disc isn't cutting it for you then you should take a look at [Havanna](https://github.com/djanowski/havanna), a project by my friend [@djanowski](https://twitter.com/djanowski).
185
+
153
186
  ## License
154
187
 
155
188
  The code is released under an MIT license. See the [LICENSE](./LICENSE) file for
@@ -157,7 +190,7 @@ more information.
157
190
 
158
191
  ## Acknowledgements
159
192
 
160
- * To [@godfoca](https://github.com/godfoca) for helping me ship a quality thing and putting up with my constant whining.
193
+ * To [@foca](https://github.com/foca) for helping me ship a quality thing and putting up with my constant whining.
161
194
  * To [@antirez](https://github,com/antirez) for Redis, Disque, and his refreshing way of programming wonderful tools.
162
195
  * To [@soveran](https://github.com/soveran) for pushing me to work on this and publishing gems that keep me enjoying ruby.
163
196
  * To [all contributors](https://github.com/pote/disc/graphs/contributors)
@@ -1,4 +1,5 @@
1
1
  require 'date'
2
+ require 'disc'
2
3
  require 'msgpack'
3
4
 
4
5
  module ActiveJob
@@ -113,7 +113,7 @@ class Disc
113
113
  disc_options.fetch(:queue, 'default')
114
114
  end
115
115
 
116
- def enqueue(args, at: nil, queue: nil)
116
+ def enqueue(args = [], at: nil, queue: nil)
117
117
  disque.push(
118
118
  queue || self.queue,
119
119
  {
@@ -1,3 +1,3 @@
1
1
  class Disc
2
- VERSION = "0.0.18"
2
+ VERSION = "0.0.19"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: disc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.18
4
+ version: 0.0.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - pote
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-21 00:00:00.000000000 Z
11
+ date: 2015-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: disque