pakyow-realtime 0.10.1 → 0.10.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/pakyow-realtime/CHANGELOG.md +7 -0
- data/pakyow-realtime/lib/pakyow-realtime/message_handlers/call_route.rb +5 -1
- data/pakyow-realtime/lib/pakyow-realtime/redis_subscription.rb +28 -37
- data/pakyow-realtime/lib/pakyow-realtime/registries/redis_registry.rb +2 -2
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3af56bba7d1aa3e3b121eb2b542d0dc4f85d35d
|
4
|
+
data.tar.gz: 33f0af0198c31f0b2b728d07a63635a2f85ad79a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf7e58a486cdef598237a63744c06069c9df16bf70c39d206d9bd18e2272e8a2035007ac3cd50d7dec232488ad89deb122d1b369a1230a229b2e6f09818dc968
|
7
|
+
data.tar.gz: 2ab01fe491a66614a021fefea6e674f68cf614fb970742b57ba2a3adca12c4dfae3716dc0c25c51ff3e3b147985730e0f657cd586fa784fdcd9da4e59aba7520
|
@@ -1,3 +1,10 @@
|
|
1
|
+
# 0.10.2 / 2015-11-15
|
2
|
+
|
3
|
+
* Adds ability to return only a partial in call-route response
|
4
|
+
* Fixes several bugs with the redis registry / subscriptions
|
5
|
+
* Fixes a bug causing qualifications to not match when using redis
|
6
|
+
* Bumps concurrent-ruby version to 1.0
|
7
|
+
|
1
8
|
# 0.10.0 / 2015-10-19
|
2
9
|
|
3
10
|
* Initial release
|
@@ -18,10 +18,14 @@ Pakyow::Realtime.handler :'call-route' do |message, session, response|
|
|
18
18
|
res = app.process(env)
|
19
19
|
|
20
20
|
container = message['container']
|
21
|
+
partial = message['partial']
|
22
|
+
|
23
|
+
composer = app.presenter.composer
|
21
24
|
|
22
25
|
if container
|
23
|
-
composer = app.presenter.composer
|
24
26
|
body = composer.container(container.to_sym).includes(composer.partials).to_s
|
27
|
+
elsif partial
|
28
|
+
body = composer.partial(partial.to_sym).includes(composer.partials).to_s
|
25
29
|
else
|
26
30
|
body = res[2].body
|
27
31
|
end
|
@@ -7,51 +7,42 @@ module Pakyow
|
|
7
7
|
#
|
8
8
|
# @api private
|
9
9
|
class RedisSubscription
|
10
|
-
|
10
|
+
SIGNAL_UNSUBSCRIBE = :unsubscribe
|
11
11
|
|
12
12
|
def initialize
|
13
13
|
@redis = ::Redis.new(Config.realtime.redis)
|
14
|
-
@channels = []
|
15
|
-
|
16
|
-
ObjectSpace.define_finalizer(self, self.class.finalize)
|
17
14
|
end
|
18
15
|
|
19
|
-
def
|
20
|
-
|
21
|
-
|
22
|
-
|
16
|
+
def subscribe(channels = [])
|
17
|
+
channels << signal_channel
|
18
|
+
|
19
|
+
Concurrent::Future.execute {
|
20
|
+
@redis.subscribe(*channels) do |on|
|
21
|
+
on.message do |channel, msg|
|
22
|
+
if channel == signal_channel
|
23
|
+
if msg == SIGNAL_UNSUBSCRIBE
|
24
|
+
@redis.unsubscribe
|
25
|
+
return
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
msg = JSON.parse(msg)
|
30
|
+
|
31
|
+
if msg.is_a?(Hash)
|
32
|
+
msg[:__propagated] = true
|
33
|
+
elsif msg.is_a?(Array)
|
34
|
+
msg << :__propagated
|
35
|
+
end
|
36
|
+
|
37
|
+
context = Pakyow::Realtime::Context.new(Pakyow.app)
|
38
|
+
context.push(msg, channel)
|
39
|
+
end
|
40
|
+
end
|
23
41
|
}
|
24
42
|
end
|
25
43
|
|
26
|
-
def
|
27
|
-
|
28
|
-
@channels = channels
|
29
|
-
|
30
|
-
run
|
31
|
-
end
|
32
|
-
|
33
|
-
def unsubscribe
|
34
|
-
return if @channels.empty?
|
35
|
-
@redis.unsubscribe(*@channels)
|
36
|
-
end
|
37
|
-
|
38
|
-
private
|
39
|
-
|
40
|
-
def run
|
41
|
-
@redis.subscribe(*@channels) do |on|
|
42
|
-
on.message do |channel, msg|
|
43
|
-
msg = JSON.parse(msg)
|
44
|
-
|
45
|
-
if msg.is_a?(Hash)
|
46
|
-
msg[:__propagated] = true
|
47
|
-
elsif msg.is_a?(Array)
|
48
|
-
msg << :__propagated
|
49
|
-
end
|
50
|
-
|
51
|
-
context = Pakyow::Realtime::Context.new(Pakyow.app)
|
52
|
-
context.push(msg, channel)
|
53
|
-
end
|
54
|
-
end
|
44
|
+
def signal_channel
|
45
|
+
"pw:#{object_id}:signal"
|
55
46
|
end
|
56
47
|
end
|
57
48
|
end
|
@@ -71,12 +71,12 @@ module Pakyow
|
|
71
71
|
# subscriber with the current channels.
|
72
72
|
def resubscribe
|
73
73
|
if @subscriber
|
74
|
-
@subscriber.
|
74
|
+
Pakyow::Realtime.redis.publish(@subscriber.signal_channel, RedisSubscription::SIGNAL_UNSUBSCRIBE)
|
75
75
|
else
|
76
76
|
@subscriber = RedisSubscription.new
|
77
77
|
end
|
78
78
|
|
79
|
-
@subscriber.
|
79
|
+
@subscriber.subscribe(@channels)
|
80
80
|
end
|
81
81
|
|
82
82
|
# Returns the key used to store channels.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pakyow-realtime
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bryan Powell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pakyow-support
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.10.
|
19
|
+
version: 0.10.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.10.
|
26
|
+
version: 0.10.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: pakyow-core
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.10.
|
33
|
+
version: 0.10.2
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.10.
|
40
|
+
version: 0.10.2
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: websocket_parser
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
75
|
+
version: '1.0'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
82
|
+
version: '1.0'
|
83
83
|
description: WebSockets and realtime channels for Pakyow
|
84
84
|
email: bryan@metabahn.com
|
85
85
|
executables: []
|
@@ -130,3 +130,4 @@ signing_key:
|
|
130
130
|
specification_version: 4
|
131
131
|
summary: Pakyow Realtime
|
132
132
|
test_files: []
|
133
|
+
has_rdoc:
|