disc 0.0.3 → 0.0.4
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/bin/disc +16 -2
- data/disc.gemspec +1 -1
- data/disc_init_example.rb +1 -0
- data/lib/disc.rb +14 -8
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e27c1afc35fddfc586142db0d638d01359e2805
|
4
|
+
data.tar.gz: 80c10659857e47428b32b03afa824705f7a31f99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9fc19d235cccc931573cd69bf9b8d103f6a3330632467d60ec77e5cb85963585ae11ddca194d2b63e17445e10108b5689edaec3fb2ff9c108af26a95d018250
|
7
|
+
data.tar.gz: 9ae8526e66733e2e7c8a91751474a9b1f0a01a9d96b8e6f1e2f9af57cf57db9d697330e9c9e4a5f08ff90faa500334edcbaf70c4f0ed903f49c6eeb7780dd38d
|
data/bin/disc
CHANGED
@@ -5,10 +5,24 @@ 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(
|
8
|
+
STDOUT.puts(
|
9
|
+
"[Notice] Disc running in celluloid-mode! Current DISC_CONCURRENCY is\
|
10
|
+
#{ concurrency }."
|
11
|
+
)
|
9
12
|
|
13
|
+
class Disc::WorkerGroup < Celluloid::SupervisionGroup
|
14
|
+
pool Disc::Worker,
|
15
|
+
size: ENV.fetch('DISC_CONCURRENCY', '25').to_i,
|
16
|
+
as: :worker_pool,
|
17
|
+
args: [{ run: true }]
|
18
|
+
end
|
19
|
+
|
20
|
+
Disc::WorkerGroup.run
|
10
21
|
|
11
22
|
else
|
12
|
-
STDOUT.puts(
|
23
|
+
STDOUT.puts(
|
24
|
+
"[Notice] Disc running in non-threaded mode, make sure to `require 'cellulloid'`\
|
25
|
+
for a significant powerup!"
|
26
|
+
)
|
13
27
|
Disc::Worker.run
|
14
28
|
end
|
data/disc.gemspec
CHANGED
data/disc_init_example.rb
CHANGED
data/lib/disc.rb
CHANGED
@@ -27,6 +27,8 @@ class Disc
|
|
27
27
|
end
|
28
28
|
|
29
29
|
class Worker
|
30
|
+
include Celluloid if defined?(Celluloid)
|
31
|
+
|
30
32
|
attr_reader :disque,
|
31
33
|
:queues,
|
32
34
|
:timeout,
|
@@ -36,20 +38,24 @@ class Disc
|
|
36
38
|
new.run
|
37
39
|
end
|
38
40
|
|
39
|
-
def initialize(
|
40
|
-
@disque = disque || Disc.disque
|
41
|
-
@count
|
41
|
+
def initialize(options = {})
|
42
|
+
@disque = options[:disque] || Disc.disque
|
43
|
+
@count = (options[:count] || ENV.fetch('DISQUE_COUNT', '1')).to_i
|
44
|
+
@timeout = (options[:timeout] || ENV.fetch('DISQUE_TIMEOUT', '2000')).to_i
|
45
|
+
|
42
46
|
@queues = case
|
43
|
-
when queues.is_a?(Array)
|
44
|
-
queues
|
45
|
-
when queues.is_a?(String)
|
46
|
-
queues.split(',')
|
47
|
-
when queues.nil?
|
47
|
+
when options[:queues].is_a?(Array)
|
48
|
+
options[:queues]
|
49
|
+
when options[:queues].is_a?(String)
|
50
|
+
options[:queues].split(',')
|
51
|
+
when options[:queues].nil?
|
48
52
|
ENV.fetch('QUEUES', 'default').split(',')
|
49
53
|
else
|
50
54
|
raise 'Invalid Disque Queues'
|
51
55
|
end
|
52
56
|
|
57
|
+
self.run if options[:run]
|
58
|
+
|
53
59
|
self
|
54
60
|
end
|
55
61
|
|