em-resque 1.0.0.beta7 → 1.0.0.beta8

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  module EventMachine
2
2
  module Resque
3
- Version = VERSION = '1.0.0.beta7'
3
+ Version = VERSION = '1.0.0.beta8'
4
4
  end
5
5
  end
@@ -37,15 +37,15 @@ module EventMachine
37
37
 
38
38
  raise(ArgumentError, "Should have at least one fiber") if @fibers_count.to_i < 1
39
39
 
40
+ build_workers
41
+ build_fibers
40
42
  create_pidfile
41
43
  end
42
44
 
43
45
  # Start the machine and start polling queues.
44
46
  def start
45
47
  EM.synchrony do
46
- EM::Resque.redis = @redis_uri
47
- build_workers
48
- build_fibers
48
+ EM::Resque.initialize_redis(@redis_uri, @fibers_count)
49
49
  trap_signals
50
50
  prune_dead_workers
51
51
  @fibers.each(&:resume)
data/lib/em-resque.rb CHANGED
@@ -1,12 +1,13 @@
1
1
  require 'resque'
2
2
  require 'em-synchrony'
3
3
  require 'em-synchrony/em-redis'
4
+ require 'em-synchrony/connection_pool'
4
5
  require 'uri'
5
6
 
6
7
  module EM::Resque
7
8
  extend Resque
8
9
 
9
- def self.redis=(server)
10
+ def self.initialize_redis(server, pool_size = 1)
10
11
  case server
11
12
  when String
12
13
  opts = if server =~ /redis\:\/\//
@@ -20,7 +21,9 @@ module EM::Resque
20
21
 
21
22
  namespace ||= :resque
22
23
 
23
- redis = EM::Protocols::Redis.connect(opts)
24
+ redis = EventMachine::Synchrony::ConnectionPool.new(:size => pool_size) do
25
+ EM::Protocols::Redis.connect(opts)
26
+ end
24
27
 
25
28
  Resque.redis = Redis::Namespace.new(namespace, :redis => redis)
26
29
  when Redis::Namespace
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: em-resque
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta7
4
+ version: 1.0.0.beta8
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-20 00:00:00.000000000 Z
12
+ date: 2012-01-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: resque
16
- requirement: &16410000 !ruby/object:Gem::Requirement
16
+ requirement: &5445180 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.19.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *16410000
24
+ version_requirements: *5445180
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: em-synchrony
27
- requirement: &16408840 !ruby/object:Gem::Requirement
27
+ requirement: &5444180 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.0.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *16408840
35
+ version_requirements: *5444180
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: em-redis
38
- requirement: &16404320 !ruby/object:Gem::Requirement
38
+ requirement: &5441300 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: 0.3.0
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *16404320
46
+ version_requirements: *5441300
47
47
  description: ! " Em-resque is a version of Resque, which offers non-blocking and
48
48
  non-forking\n workers. The idea is to have fast as possible workers for tasks
49
49
  with lots of\n IO like pinging third party servers or hitting the database.\n\n