em-resque 1.0.0.beta6 → 1.0.0.beta7

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.beta6'
3
+ Version = VERSION = '1.0.0.beta7'
4
4
  end
5
5
  end
@@ -33,7 +33,7 @@ module EventMachine
33
33
  @verbose = opts[:logging] || opts[:verbose] || false
34
34
  @very_verbose = opts[:vverbose] || false
35
35
  @pidfile = opts[:pidfile]
36
- @redis = opts[:redis]
36
+ @redis_uri = opts[:redis] || "redis://127.0.0.1:6379"
37
37
 
38
38
  raise(ArgumentError, "Should have at least one fiber") if @fibers_count.to_i < 1
39
39
 
@@ -43,11 +43,11 @@ module EventMachine
43
43
  # Start the machine and start polling queues.
44
44
  def start
45
45
  EM.synchrony do
46
- EM::Resque.redis = redis_instance(@redis)
46
+ EM::Resque.redis = @redis_uri
47
47
  build_workers
48
48
  build_fibers
49
- prune_dead_workers
50
49
  trap_signals
50
+ prune_dead_workers
51
51
  @fibers.each(&:resume)
52
52
  system_monitor.resume
53
53
  end
@@ -116,28 +116,6 @@ module EventMachine
116
116
  def create_pidfile
117
117
  File.open(@pidfile, 'w') { |f| f << Process.pid } if @pidfile
118
118
  end
119
-
120
- def redis_instance(server)
121
- case server
122
- when String
123
- if server =~ /redis\:\/\//
124
- host, port = server.split('/', 3).last.split(':')
125
- redis = EM::Protocols::Redis.connect(:host => host, :port => port, :thread_safe => true)
126
- else
127
- server, namespace = server.split('/', 2)
128
- host, port, db = server.split(':')
129
- redis = EM::Protocols::Redis.new(:host => host, :port => port,
130
- :thread_safe => true, :db => db)
131
- end
132
- namespace ||= :resque
133
-
134
- Redis::Namespace.new(namespace, :redis => redis)
135
- when Redis::Namespace
136
- server
137
- else
138
- Redis::Namespace.new(:resque, :redis => server)
139
- end
140
- end
141
119
  end
142
120
  end
143
121
  end
data/lib/em-resque.rb CHANGED
@@ -1,6 +1,32 @@
1
1
  require 'resque'
2
+ require 'em-synchrony'
2
3
  require 'em-synchrony/em-redis'
4
+ require 'uri'
3
5
 
4
6
  module EM::Resque
5
7
  extend Resque
8
+
9
+ def self.redis=(server)
10
+ case server
11
+ when String
12
+ opts = if server =~ /redis\:\/\//
13
+ uri = URI.parse(server)
14
+ {:host => uri.host, :port => uri.port}
15
+ else
16
+ server, namespace = server.split('/', 2)
17
+ host, port, db = server.split(':')
18
+ {:host => host, :port => port, :thread_safe => true, :db => db}
19
+ end
20
+
21
+ namespace ||= :resque
22
+
23
+ redis = EM::Protocols::Redis.connect(opts)
24
+
25
+ Resque.redis = Redis::Namespace.new(namespace, :redis => redis)
26
+ when Redis::Namespace
27
+ Resque.redis = server
28
+ else
29
+ Resque.redis = Redis::Namespace.new(namespace, :redis => server)
30
+ end
31
+ end
6
32
  end
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.beta6
4
+ version: 1.0.0.beta7
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-17 00:00:00.000000000 Z
12
+ date: 2012-01-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: resque
16
- requirement: &9351180 !ruby/object:Gem::Requirement
16
+ requirement: &16410000 !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: *9351180
24
+ version_requirements: *16410000
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: em-synchrony
27
- requirement: &9350600 !ruby/object:Gem::Requirement
27
+ requirement: &16408840 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,18 +32,18 @@ dependencies:
32
32
  version: 1.0.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *9350600
35
+ version_requirements: *16408840
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: em-redis
38
- requirement: &9349920 !ruby/object:Gem::Requirement
38
+ requirement: &16404320 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
- - - ! '>='
41
+ - - ~>
42
42
  - !ruby/object:Gem::Version
43
- version: '0'
43
+ version: 0.3.0
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *9349920
46
+ version_requirements: *16404320
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