disc 0.0.3 → 0.0.4

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: 65752990e4c8bb6460341783b4646d78098752f5
4
- data.tar.gz: de08052069da3cd2d1147ed2cd4afcaff2b2bd7d
3
+ metadata.gz: 7e27c1afc35fddfc586142db0d638d01359e2805
4
+ data.tar.gz: 80c10659857e47428b32b03afa824705f7a31f99
5
5
  SHA512:
6
- metadata.gz: faac2698db6e1125aa696b8d3bb54a932fbc74a30947dbb6f7aa6987579145c007913f6da41851ebc0b796b82bdf1f90dd1c2948e373d4d7812030fefe19515e
7
- data.tar.gz: 8db24310748e9c68a29f51b57d6fe6f887e5eaa867b6fed2aa99d88150f71583e2d91f5ab33804bf9f64cd193507efe53f3a3304f2a5b1106aaedde65d0409dd
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("[Notice] Disc running in celluloid-mode! Current DISC_CONCURRENCY is #{ concurrency }.")
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("[Notice] Disc running in non-threaded mode, make sure to `require 'cellulloid'` for a significant powerup!")
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
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'disc'
3
- s.version = '0.0.3'
3
+ s.version = '0.0.4'
4
4
  s.summary = 'A simple disque and powerful job implementation'
5
5
  s.description = ''
6
6
  s.authors = ['pote']
data/disc_init_example.rb CHANGED
@@ -1 +1,2 @@
1
+ require 'celluloid'
1
2
  Dir.glob('./**/*.rb') { |f| require_relative f }
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(disque: nil , queues: nil, count: 1, timeout: nil)
40
- @disque = disque || Disc.disque
41
- @count, @timeout = count, timeout
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
 
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.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - pote