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 +4 -4
- data/README.md +54 -23
- data/bin/disc +5 -1
- data/disc-wars.jpg +0 -0
- data/disc.gemspec +1 -1
- data/disc_init_example.rb +1 -0
- data/examples/greeter.rb +10 -0
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65752990e4c8bb6460341783b4646d78098752f5
|
4
|
+
data.tar.gz: de08052069da3cd2d1147ed2cd4afcaff2b2bd7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: faac2698db6e1125aa696b8d3bb54a932fbc74a30947dbb6f7aa6987579145c007913f6da41851ebc0b796b82bdf1f90dd1c2948e373d4d7812030fefe19515e
|
7
|
+
data.tar.gz: 8db24310748e9c68a29f51b57d6fe6f887e5eaa867b6fed2aa99d88150f71583e2d91f5ab33804bf9f64cd193507efe53f3a3304f2a5b1106aaedde65d0409dd
|
data/README.md
CHANGED
@@ -1,46 +1,77 @@
|
|
1
1
|
# Disc
|
2
2
|
|
3
|
-
Disc
|
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
|
+

|
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
|
-
|
20
|
-
|
22
|
+
class CreateGameGrid
|
23
|
+
include Disc::Job
|
24
|
+
disc queue: 'urgent'
|
21
25
|
|
22
|
-
|
23
|
-
|
26
|
+
def perform(type)
|
27
|
+
# perform rather lengthy operations here.
|
28
|
+
end
|
24
29
|
end
|
25
|
-
|
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.
|
38
|
-
```
|
40
|
+
```ruby
|
41
|
+
CreateGameGrid.enqueue_at(DateTime.new(2015, 12, 31), 'disc_arena')
|
42
|
+
```
|
39
43
|
|
40
|
-
5.
|
44
|
+
5. Create a file that requires anything needed for your jobs to run
|
41
45
|
|
42
|
-
```
|
43
|
-
|
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
|
-
|
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
|
data/disc-wars.jpg
ADDED
Binary file
|
data/disc.gemspec
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
Dir.glob('./**/*.rb') { |f| require_relative f }
|
data/examples/greeter.rb
ADDED
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.
|
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
|