volcano-sdk 0.10.0 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 59e652b75cb01f8a353cca787d8e97ecce893091202389d6eb05d16898553fe4
|
|
4
|
+
data.tar.gz: 1aaab53a45bb753db900c0dbb5fe0d95d27c17f36a0bc4487e396a37f10e0a7c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f1c408840aeabf36d2880bb13f8fa9ef602ecb1fa5de7e0b3db936ca48f02ce8b8dc667c6dcf52ec4637f4418f6c9b45bbf157081cbc167406752980d1c56bc2
|
|
7
|
+
data.tar.gz: 641095882ee98d37672f0c7c9a59a2051d98f4a392682df91753b999fffd2aae91a65a62e9c299569f5e1d3c96f73b4095247e168954ae7c75f6e36f5a71fed2
|
|
@@ -35,7 +35,7 @@ module Volcano
|
|
|
35
35
|
include ProtocolRecoveryPosition
|
|
36
36
|
|
|
37
37
|
Failure = Data.define(:error)
|
|
38
|
-
Pending = Data.define(:queue, :on_reply)
|
|
38
|
+
Pending = Data.define(:queue, :on_reply, :reply_key)
|
|
39
39
|
private_constant :Pending
|
|
40
40
|
Events = Data.define(:on_close, :on_error, :on_failure)
|
|
41
41
|
DEFAULT_REQUEST_TIMEOUT = 10
|
|
@@ -81,7 +81,7 @@ module Volcano
|
|
|
81
81
|
end
|
|
82
82
|
|
|
83
83
|
def connect(token:)
|
|
84
|
-
result = request { |id| self.class.connect(id: id, token: token) }
|
|
84
|
+
result = request('connect') { |id| self.class.connect(id: id, token: token) }
|
|
85
85
|
ensure_open!
|
|
86
86
|
@connected = true
|
|
87
87
|
result
|
|
@@ -99,20 +99,22 @@ module Volcano
|
|
|
99
99
|
end
|
|
100
100
|
end
|
|
101
101
|
|
|
102
|
-
def publish(channel:, data:)
|
|
102
|
+
def publish(channel:, data:)
|
|
103
|
+
request('publish') { |id| self.class.publish(id: id, channel: channel, data: data) }
|
|
104
|
+
end
|
|
103
105
|
|
|
104
106
|
def unsubscribe(channel:)
|
|
105
107
|
@subscription_lock.acquire do
|
|
106
108
|
ensure_open!
|
|
107
109
|
next {} unless @subscriptions.include?(channel)
|
|
108
110
|
|
|
109
|
-
result = request { |id| self.class.unsubscribe(id: id, channel: channel) }
|
|
111
|
+
result = request('unsubscribe') { |id| self.class.unsubscribe(id: id, channel: channel) }
|
|
110
112
|
@subscriptions.delete(channel)
|
|
111
113
|
result
|
|
112
114
|
end
|
|
113
115
|
end
|
|
114
116
|
|
|
115
|
-
def presence(channel:) = request { |id| self.class.presence(id: id, channel: channel) }
|
|
117
|
+
def presence(channel:) = request('presence') { |id| self.class.presence(id: id, channel: channel) }
|
|
116
118
|
|
|
117
119
|
def close
|
|
118
120
|
return nil if @closed
|
|
@@ -30,7 +30,7 @@ module Volcano
|
|
|
30
30
|
pending = @pending[frame.fetch('id')]
|
|
31
31
|
return unless pending
|
|
32
32
|
|
|
33
|
-
reply = reply_value(frame)
|
|
33
|
+
reply = reply_value(frame, pending.reply_key)
|
|
34
34
|
pending.queue.enqueue(apply_reply_hook(pending, reply))
|
|
35
35
|
end
|
|
36
36
|
|
|
@@ -43,9 +43,9 @@ module Volcano
|
|
|
43
43
|
Protocol::Failure.new(error: e)
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
-
def reply_value(frame)
|
|
46
|
+
def reply_value(frame, reply_key)
|
|
47
47
|
error = frame['error']
|
|
48
|
-
return frame
|
|
48
|
+
return frame.fetch(reply_key) { frame.fetch('result') { frame.except('id') } } unless error
|
|
49
49
|
|
|
50
50
|
message = error['message'] || 'realtime command failed'
|
|
51
51
|
Protocol::Failure.new(error: ServerError.new(message, code: error['code']))
|
|
@@ -8,9 +8,9 @@ module Volcano
|
|
|
8
8
|
module IO
|
|
9
9
|
private
|
|
10
10
|
|
|
11
|
-
def request(on_reply: nil)
|
|
11
|
+
def request(reply_key, on_reply: nil)
|
|
12
12
|
ensure_open!
|
|
13
|
-
id, reply_queue = register_request(on_reply)
|
|
13
|
+
id, reply_queue = register_request(reply_key, on_reply)
|
|
14
14
|
write_frame(yield(id))
|
|
15
15
|
reply = await_reply(reply_queue)
|
|
16
16
|
raise reply.error if reply.is_a?(Failure)
|
|
@@ -22,14 +22,14 @@ module Volcano
|
|
|
22
22
|
@pending.delete(id) if defined?(id)
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
-
def register_request(on_reply)
|
|
25
|
+
def register_request(reply_key, on_reply)
|
|
26
26
|
if @pending.length >= @max_pending
|
|
27
27
|
raise PendingLimitError, "realtime pending command limit #{@max_pending} reached"
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
@next_id += 1
|
|
31
31
|
queue = Async::Queue.new
|
|
32
|
-
@pending[@next_id] = Pending.new(queue: queue, on_reply: on_reply)
|
|
32
|
+
@pending[@next_id] = Pending.new(queue: queue, on_reply: on_reply, reply_key: reply_key)
|
|
33
33
|
[@next_id, queue]
|
|
34
34
|
end
|
|
35
35
|
|
data/lib/volcano/version.rb
CHANGED