superfeedr-em-redis 0.3.5 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/em-redis/redis_protocol.rb +34 -18
- data/lib/em-redis/version.rb +1 -1
- metadata +34 -62
@@ -342,6 +342,7 @@ module EventMachine
|
|
342
342
|
@db = (options[:db] || 0).to_i
|
343
343
|
@password = options[:password]
|
344
344
|
@logger = options[:logger]
|
345
|
+
@subscriptions = {} # Subscriptions are empty
|
345
346
|
@error_callback = lambda do |code|
|
346
347
|
err = RedisError.new
|
347
348
|
err.code = code
|
@@ -452,27 +453,42 @@ module EventMachine
|
|
452
453
|
return
|
453
454
|
end
|
454
455
|
end
|
455
|
-
|
456
|
-
callback = @redis_callbacks.shift
|
457
|
-
commands, pipelined, blk = callback
|
458
|
-
@values ||= []
|
459
|
-
command = commands[@values.size]
|
460
456
|
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
457
|
+
if value && value[0] == "message"
|
458
|
+
# PubSub
|
459
|
+
## We need to call the subscription block!
|
460
|
+
@subscriptions[value[1]].call(value[2]) if @subscriptions[value[1]]
|
461
|
+
else
|
462
|
+
# Others
|
463
|
+
@values ||= []
|
464
|
+
callback = @redis_callbacks.shift
|
465
|
+
commands, pipelined, blk = callback
|
466
|
+
command = commands[@values.size]
|
467
|
+
processor = REPLY_PROCESSOR[command[0]]
|
468
|
+
value = processor.call(value) if processor
|
469
|
+
@values.push(value)
|
470
|
+
if @values.size == commands.size
|
471
|
+
if !pipelined
|
472
|
+
# This was not a PIPELINE!
|
473
|
+
# If the command was a subscribe, we want to keep track of it!
|
474
|
+
if(@values[0] && @values[0][0] == "subscribe")
|
475
|
+
@subscriptions[@values[0][1]] = blk
|
476
|
+
else
|
477
|
+
blk.call(@values[0]) if blk
|
478
|
+
end
|
479
|
+
else
|
480
|
+
if(@values && @values[0] == "subscribe")
|
481
|
+
@subscriptions[@values[1]] = blk
|
482
|
+
else
|
483
|
+
blk.call(@values) if blk
|
484
|
+
end
|
485
|
+
end
|
486
|
+
@values = []
|
468
487
|
else
|
469
|
-
|
488
|
+
# We need to wait for the other commands to succeed as well, so we repipe.
|
489
|
+
@redis_callbacks.unshift([commands, pipelined, blk])
|
470
490
|
end
|
471
|
-
|
472
|
-
else
|
473
|
-
# We need to wait for the other commands to succeed as well
|
474
|
-
@redis_callbacks.unshift([commands, pipelined, blk])
|
475
|
-
end
|
491
|
+
end
|
476
492
|
end
|
477
493
|
|
478
494
|
def unbind
|
data/lib/em-redis/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,10 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: superfeedr-em-redis
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 3
|
9
|
-
- 5
|
10
|
-
version: 0.3.5
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.6
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Jonathan Broad
|
14
9
|
- Eugene Pimenov
|
15
10
|
- Stephan Maka
|
@@ -17,50 +12,37 @@ authors:
|
|
17
12
|
autorequire:
|
18
13
|
bindir: bin
|
19
14
|
cert_chain: []
|
20
|
-
|
21
|
-
date: 2011-02-26 00:00:00 +01:00
|
15
|
+
date: 2012-02-13 00:00:00.000000000 -08:00
|
22
16
|
default_executable:
|
23
|
-
dependencies:
|
24
|
-
- !ruby/object:Gem::Dependency
|
17
|
+
dependencies:
|
18
|
+
- !ruby/object:Gem::Dependency
|
25
19
|
name: eventmachine
|
26
|
-
|
27
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
requirement: &2164384740 !ruby/object:Gem::Requirement
|
28
21
|
none: false
|
29
|
-
requirements:
|
30
|
-
- -
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
|
33
|
-
segments:
|
34
|
-
- 0
|
35
|
-
version: "0"
|
22
|
+
requirements:
|
23
|
+
- - ! '>='
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: '0'
|
36
26
|
type: :runtime
|
37
|
-
version_requirements: *id001
|
38
|
-
- !ruby/object:Gem::Dependency
|
39
|
-
name: bundler
|
40
27
|
prerelease: false
|
41
|
-
|
28
|
+
version_requirements: *2164384740
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: bundler
|
31
|
+
requirement: &2164384120 !ruby/object:Gem::Requirement
|
42
32
|
none: false
|
43
|
-
requirements:
|
33
|
+
requirements:
|
44
34
|
- - ~>
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
hash: 15424249
|
47
|
-
segments:
|
48
|
-
- 1
|
49
|
-
- 0
|
50
|
-
- rc
|
51
|
-
- 6
|
35
|
+
- !ruby/object:Gem::Version
|
52
36
|
version: 1.0.rc.6
|
53
37
|
type: :development
|
54
|
-
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: *2164384120
|
55
40
|
description: An eventmachine-based implementation of the Redis protocol
|
56
41
|
email:
|
57
42
|
executables: []
|
58
|
-
|
59
43
|
extensions: []
|
60
|
-
|
61
44
|
extra_rdoc_files: []
|
62
|
-
|
63
|
-
files:
|
45
|
+
files:
|
64
46
|
- lib/em-redis/redis_protocol.rb
|
65
47
|
- lib/em-redis/version.rb
|
66
48
|
- lib/em-redis.rb
|
@@ -68,36 +50,26 @@ files:
|
|
68
50
|
has_rdoc: true
|
69
51
|
homepage: http://github.com/superfeedr/em-redis
|
70
52
|
licenses: []
|
71
|
-
|
72
53
|
post_install_message:
|
73
54
|
rdoc_options: []
|
74
|
-
|
75
|
-
require_paths:
|
55
|
+
require_paths:
|
76
56
|
- lib
|
77
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
58
|
none: false
|
79
|
-
requirements:
|
80
|
-
- -
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
|
83
|
-
|
84
|
-
- 0
|
85
|
-
version: "0"
|
86
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
64
|
none: false
|
88
|
-
requirements:
|
89
|
-
- -
|
90
|
-
- !ruby/object:Gem::Version
|
91
|
-
|
92
|
-
segments:
|
93
|
-
- 0
|
94
|
-
version: "0"
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
95
69
|
requirements: []
|
96
|
-
|
97
70
|
rubyforge_project:
|
98
|
-
rubygems_version: 1.
|
71
|
+
rubygems_version: 1.6.2
|
99
72
|
signing_key:
|
100
73
|
specification_version: 3
|
101
74
|
summary: An eventmachine-based implementation of the Redis protocol
|
102
75
|
test_files: []
|
103
|
-
|