disc 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f29a84d4cefb49cf688a2fe2fe2bc5fcfc0a29d6
4
- data.tar.gz: 2314325e125adf600c3dc6f1190d9677574dc88a
3
+ metadata.gz: 65752990e4c8bb6460341783b4646d78098752f5
4
+ data.tar.gz: de08052069da3cd2d1147ed2cd4afcaff2b2bd7d
5
5
  SHA512:
6
- metadata.gz: 8fa78c4be3782443580d74072aec81b09a6079630b7b22910a148f79f11d69d90ce178b3297ef42bee287a4d92676f685bc88d75f488184613ea4a846f71d9a2
7
- data.tar.gz: 960d4938fe9f596f77c607a1622bda422285fdce50de362189406b684af0846846a5b51963c8d99518ed1478e242cb1c7ed80eecd8c97ef89c387b7783f1da52
6
+ metadata.gz: faac2698db6e1125aa696b8d3bb54a932fbc74a30947dbb6f7aa6987579145c007913f6da41851ebc0b796b82bdf1f90dd1c2948e373d4d7812030fefe19515e
7
+ data.tar.gz: 8db24310748e9c68a29f51b57d6fe6f887e5eaa867b6fed2aa99d88150f71583e2d91f5ab33804bf9f64cd193507efe53f3a3304f2a5b1106aaedde65d0409dd
data/README.md CHANGED
@@ -1,46 +1,77 @@
1
1
  # Disc
2
2
 
3
- Disc allows you to easily leverage [antirez](http://antirez.com/)'s wonderful [Disque](https://github.com/antirez/disque) from your Ruby applications, filling the gap between your service objects and Disque.
3
+ Disc fills the gap between your Ruby service objects and [antirez](http://antirez.com/)'s wonderful [Disque](https://github.com/antirez/disque) backend.
4
+
5
+ <a href=https://www.flickr.com/photos/noodlefish/5321412234/in/photolist-91LsrP-4nrahM-91PzfG-92HS1v-8ApwqD-q5sH-dM6d74-52zUMi-cJ2iVN-cJ1Egs-hcQpne-9d9RyF-9dWnVK-b5EGYP-arSsBd-6JgG1Y-qJoCkE-88Vp8g-92M3HC-9CL8KH-97eCsN-8HtoUt-2PkxTh-993Jiy-ad7xjp-a3MKZU-8Hwxgu-raHDW-993JAC-AAEa-b9LKDR-8nW7mM-qJsPN4-6Bo8Fw-qJoFjL-9CEg7J-9RDVRc-rZWuCt-9751Cf-hZyWZw-gPqXZm-8KiTxg-dpoXjb-dpoNjB-93hj1h-9sX9ii-8KiJvr-LXLH5-dhe92T-3GQgs6" target="blank_">
6
+ ![Disc Wars!](./disc-wars.jpg)
7
+ </a>
4
8
 
5
9
  ## Usage
6
10
 
7
11
  1. Install the gem
8
12
 
9
- ```bash
10
- $ gem install disc
11
- ```
13
+ ```bash
14
+ $ gem install disc
15
+ ```
12
16
 
13
17
  2. Write your jobs
14
18
 
15
- ```ruby
16
- requie 'disc'
19
+ ```ruby
20
+ requie 'disc'
17
21
 
18
- class CreateGameGrid
19
- include Disc::Job
20
- queue :urgent
22
+ class CreateGameGrid
23
+ include Disc::Job
24
+ disc queue: 'urgent'
21
25
 
22
- def perform(type)
23
- # perform rather lengthy operations here.
26
+ def perform(type)
27
+ # perform rather lengthy operations here.
28
+ end
24
29
  end
25
- end
26
- ```
30
+ ```
27
31
 
28
32
  3. Enqueue them to perform them asynchronously
29
33
 
30
- ```ruby
31
- CreateGameGrid.enqueue('ligth_cycle')
32
- ```
34
+ ```ruby
35
+ CreateGameGrid.enqueue('ligth_cycle')
36
+ ```
33
37
 
34
38
  4. Or enqueue them to be performed at some time in the future.
35
39
 
36
- ```ruby
37
- CreateGameGrid.enqueue('disc_arena', at: DateTime.new(2015, 12, 31))
38
- ```
40
+ ```ruby
41
+ CreateGameGrid.enqueue_at(DateTime.new(2015, 12, 31), 'disc_arena')
42
+ ```
39
43
 
40
- 5. Run as many Disc Worker processes as you wish.
44
+ 5. Create a file that requires anything needed for your jobs to run
41
45
 
42
- ```bash
43
- $ DISQUE_QUEUES=urgent,default disc
44
- ```
46
+ ```ruby
47
+ # disc_init.rb
48
+ require 'ohm'
49
+ Dir.glob('jobs/**/*.rb') { |f| require_relative f }
50
+ ```
51
+
52
+ 6. Set your require file
53
+
54
+ ```bash
55
+ $ export DIC_REQUIRE='./disc_init.rb'
56
+ ```
57
+
58
+ 7. Run as many Disc Worker processes as you wish.
59
+
60
+ ```bash
61
+ $ QUEUES=urgent,default disc
62
+ ```
45
63
 
46
64
  You're done!
65
+
66
+
67
+ ### PowerUps
68
+
69
+ Disc workers can run just fine on their own, but sometimes you migth want to have each process spawning multiple threads doing this is trivial: just make sure you require [Celluloid](https://github.com/celluloid/celluloid) in your Disc init file!
70
+
71
+ ```ruby
72
+ # disq_init.rb
73
+
74
+ require 'celluloid'
75
+ ```
76
+
77
+ Whenever Disc detects that Celluloid is available it will leverage it and spawn a number of threads equal to the `DISC_CONCURRENCY` environment variable, or 25 by default.
data/bin/disc CHANGED
@@ -4,7 +4,11 @@ require 'disc'
4
4
  require ENV.fetch('DISC_REQUIRE')
5
5
 
6
6
  if defined?(Celluloid)
7
- raise 'not implemented yet genius'
7
+ concurrency = ENV.fetch('DISC_CONCURRENCY', '25').to_i
8
+ STDOUT.puts("[Notice] Disc running in celluloid-mode! Current DISC_CONCURRENCY is #{ concurrency }.")
9
+
10
+
8
11
  else
12
+ STDOUT.puts("[Notice] Disc running in non-threaded mode, make sure to `require 'cellulloid'` for a significant powerup!")
9
13
  Disc::Worker.run
10
14
  end
Binary file
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'disc'
3
- s.version = '0.0.2'
3
+ s.version = '0.0.3'
4
4
  s.summary = 'A simple disque and powerful job implementation'
5
5
  s.description = ''
6
6
  s.authors = ['pote']
@@ -0,0 +1 @@
1
+ Dir.glob('./**/*.rb') { |f| require_relative f }
@@ -0,0 +1,10 @@
1
+ require 'disc'
2
+
3
+ class Greeter
4
+ include Disc::Job
5
+ disc queue: 'test_medium'
6
+
7
+ def perform(string)
8
+ `say #{string}`
9
+ end
10
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: disc
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
  - pote
@@ -51,7 +51,10 @@ files:
51
51
  - Makefile
52
52
  - README.md
53
53
  - bin/disc
54
+ - disc-wars.jpg
54
55
  - disc.gemspec
56
+ - disc_init_example.rb
57
+ - examples/greeter.rb
55
58
  - lib/disc.rb
56
59
  - test/disc_test.rb
57
60
  homepage: https://github.com/pote/disque-job