disc 0.0.16 → 0.0.17

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: bf220b91a7f56d811b3926018f82fcf65e35956d
4
- data.tar.gz: 64c8e523ed22e996a54b31da8f2b077c08b6ff7d
3
+ metadata.gz: 725931a50fe6e4d4e96b47a0d8b5ed5666de7d60
4
+ data.tar.gz: 79806a4c3156650850e772f00a05187fafbe7e1e
5
5
  SHA512:
6
- metadata.gz: 6045fb0e6e7aaf39812feada1334c6dc288f4f6eef5d0e7f901e80d577a353c70e8b1b4e7a0df51faa5c52980b4a5dbcd7d5c415bdb2dbe56e137b9077de53ab
7
- data.tar.gz: 0e4fe719be855badefeb2aa726d61240f5908b62b383afaf4586ab1df0cd5864f1aec02c081ba4319a1fff2b79ba5ae41c918142388fefe03fce69fac711314a
6
+ metadata.gz: 6733970968415f9df5dfc02080ffecb27c9acf22f06df94787f95fc80ffc15afd619f6a7f1fb4f99e74d2cd1fed4cfe4d1a66b24efe8fa9bc3cc0e04b36a4ce1
7
+ data.tar.gz: 6fc60c37ca4fec2b2e25a9a6fe51baeae1bb26f8afe3ad5d0d0cfe740dd206876734c95af98b39b9a1c3ac2adc2fbf75f11a3365e7475a8ef9b1868ffa08a934
Binary file
data/README.md CHANGED
@@ -35,10 +35,14 @@ Disc fills the gap between your Ruby service objects and [antirez](http://antire
35
35
  CreateGameGrid.enqueue('light_cycle')
36
36
  ```
37
37
 
38
- 4. Or enqueue them to be performed at some time in the future.
38
+ 4. Or enqueue them to be performed at some time in the future, or on a queue other than it's default.
39
39
 
40
40
  ```ruby
41
- CreateGameGrid.enqueue_at(DateTime.new(2015, 12, 31), 'disc_arena')
41
+ CreateGameGrid.enqueue(
42
+ 'disc_arena',
43
+ at: DateTime.new(2015, 12, 31),
44
+ queue: 'not_so_important'
45
+ )
42
46
  ```
43
47
 
44
48
  5. Create a file that requires anything needed for your jobs to run
@@ -49,7 +53,7 @@ Disc fills the gap between your Ruby service objects and [antirez](http://antire
49
53
  Dir['./jobs/**/*.rb'].each { |job| require job }
50
54
  ```
51
55
 
52
- 7. Run as many Disc Worker processes as you wish.
56
+ 6. Run as many Disc Worker processes as you wish, requiring your `disc_init.rb` file
53
57
 
54
58
  ```bash
55
59
  $ QUEUES=urgent,default disc -r ./disc_init.rb
@@ -94,9 +98,9 @@ The error handler function gets the data of the current job as a Hash, that has
94
98
  | `'queue'` | (String) The queue from which this job was picked up. |
95
99
  | `'id'` | (String) Disque's job ID. |
96
100
 
97
- ## PowerUps
101
+ ## [Optional] Celluloid integration
98
102
 
99
- Disc workers can run just fine on their own, but if you're using
103
+ Disc workers can run just fine on their own, but if you happen to be using
100
104
  [Celluloid](https://github.com/celluloid/celluloid) you might want Disc to take
101
105
  advantage of it and spawn multiple worker threads per process, doing this is
102
106
  trivial! Just require Celluloid before your init file:
@@ -144,7 +148,7 @@ As always, make sure your `disc_init.rb` file requires the necessary jobs and yo
144
148
 
145
149
  ## A note on stability
146
150
 
147
- 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, Disque still gives me the occasional segfault when running Disc's test suite.
151
+ 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.
148
152
 
149
153
  ## License
150
154
 
@@ -157,3 +161,9 @@ more information.
157
161
  * To [@antirez](https://github,com/antirez) for Redis, Disque, and his refreshing way of programming wonderful tools.
158
162
  * To [@soveran](https://github.com/soveran) for pushing me to work on this and publishing gems that keep me enjoying ruby.
159
163
  * To [all contributors](https://github.com/pote/disc/graphs/contributors)
164
+
165
+ ## Sponsorship
166
+
167
+ This open source tool is proudly sponsored by [13Floor](http://13Floor.org)
168
+
169
+ ![13Floor](./13Floor-circulo-1.png)
data/lib/disc/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Disc
2
- VERSION = "0.0.16"
2
+ VERSION = "0.0.17"
3
3
  end
data/lib/disc.rb CHANGED
@@ -113,19 +113,15 @@ class Disc
113
113
  disc_options.fetch(:queue, 'default')
114
114
  end
115
115
 
116
- def enqueue(*args)
117
- enqueue_at(nil, *args)
118
- end
119
-
120
- def enqueue_at(datetime, *args)
116
+ def enqueue(args, at: nil, queue: nil)
121
117
  disque.push(
122
- queue,
118
+ queue || self.queue,
123
119
  {
124
120
  class: self.name,
125
- arguments: args
121
+ arguments: Array(args)
126
122
  }.to_msgpack,
127
123
  Disc.disque_timeout,
128
- delay: datetime.nil? ? nil : (datetime.to_time.to_i - DateTime.now.to_time.to_i)
124
+ delay: at.nil? ? nil : (at.to_time.to_i - DateTime.now.to_time.to_i)
129
125
  )
130
126
  end
131
127
  end
data/test/disc_test.rb CHANGED
@@ -35,7 +35,7 @@ end
35
35
 
36
36
  scope do
37
37
  test 'jobs are enqueued to the correct Disque queue with appropriate parameters and class' do
38
- jobid = Echoer.enqueue('one argument', { random: 'data' }, 3)
38
+ jobid = Echoer.enqueue(['one argument', { random: 'data' }, 3])
39
39
 
40
40
  jobs = Array(Disc.disque.fetch(from: ['test'], timeout: Disc.disque_timeout, count: 1))
41
41
  assert jobs.any?
@@ -58,9 +58,8 @@ scope do
58
58
  end
59
59
  end
60
60
 
61
- test 'enqueue_at behaves properly' do
62
- in_3_seconds = (Time.now + 3).to_datetime
63
- jobid = Echoer.enqueue_at(in_3_seconds, 'one argument', { random: 'data' }, 3)
61
+ test 'enqueue at timestamp behaves properly' do
62
+ jobid = Echoer.enqueue(['one argument', { random: 'data' }, 3], at: Time.now + 3)
64
63
 
65
64
  jobs = Array(Disc.disque.fetch(from: ['test'], timeout: Disc.disque_timeout, count: 1))
66
65
  assert jobs.empty?
@@ -87,7 +86,7 @@ scope do
87
86
 
88
87
  test 'jobs are executed' do
89
88
  begin
90
- Echoer.enqueue('one argument', { random: 'data' }, 3)
89
+ Echoer.enqueue(['one argument', { random: 'data' }, 3])
91
90
 
92
91
  cout, _, pid = PTY.spawn(
93
92
  'QUEUES=test ruby -Ilib bin/disc -r ./examples/echoer'
@@ -99,10 +98,9 @@ scope do
99
98
 
100
99
  matched = false
101
100
  counter = 0
102
- while !matched && counter < 5
101
+ while !matched && counter < 3
103
102
  counter += 1
104
103
  matched = cout.gets.match(/First: one argument, Second: {"random"=>"data"}, Third: 3/)
105
- sleep(1) unless matched
106
104
  end
107
105
 
108
106
  assert matched
@@ -130,7 +128,7 @@ scope do
130
128
  printed_job: false
131
129
  }
132
130
 
133
- while tasks.values.include?(false) && counter < 10
131
+ while tasks.values.include?(false) && counter < 5
134
132
  counter += 1
135
133
  output = cout.gets
136
134
 
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.16
4
+ version: 0.0.17
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-18 00:00:00.000000000 Z
11
+ date: 2015-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: disque
@@ -63,6 +63,7 @@ files:
63
63
  - ".env.sample"
64
64
  - ".gems"
65
65
  - ".gitignore"
66
+ - 13Floor-circulo-1.png
66
67
  - CONTRIBUTING.md
67
68
  - LICENSE
68
69
  - Makefile