cocaine-framework 0.12.0.pre.rc9 → 0.12.0.pre.rc10
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 +4 -4
- data/lib/cocaine/cocaine.rb +19 -11
- data/lib/cocaine/version.rb +1 -1
- metadata +30 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8575f791e2fcb8c473c4d1c2f93bb83f0d878695
|
4
|
+
data.tar.gz: 6794e2aafa782f1e808598b4de99854f53e56fdf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 084a79f149c0e482ea09004a446c8bd7f6aa475e790ca3d9b7d4aa486b75b2b8d46c9e367e767342778318420bf1f925d6b230ba0b88848bb14076c2e2cd9798
|
7
|
+
data.tar.gz: bfa70252a8e27ff0ff3c47a1b197e74ff8f08f5b0ef2cfc75eb004a50b6638913b524411713657935504386e88aa3e7b9eb4e168fe2f3e5903a5c8d4ac85c8d1
|
data/lib/cocaine/cocaine.rb
CHANGED
@@ -85,20 +85,23 @@ module Cocaine
|
|
85
85
|
# [Detail]
|
86
86
|
# Write-only part for shared reader state.
|
87
87
|
class TxMailbox < Mailbox
|
88
|
-
def initialize(queue, tree)
|
88
|
+
def initialize(queue, tree, session, &block)
|
89
89
|
super queue
|
90
90
|
|
91
91
|
@tree = Hash.new
|
92
92
|
tree.each do |id, (method, txtree, rxtree)|
|
93
93
|
@tree[id] = [method.to_sym, txtree]
|
94
94
|
end
|
95
|
+
|
96
|
+
@session = session
|
97
|
+
@close = block
|
95
98
|
end
|
96
99
|
|
97
100
|
def push(id, payload)
|
98
101
|
method, txtree = @tree[id]
|
99
102
|
if txtree && txtree.empty?
|
100
|
-
# Todo: Close.
|
101
103
|
LOG.debug "Closing RX channel #{self}"
|
104
|
+
@close.call @session
|
102
105
|
end
|
103
106
|
|
104
107
|
@queue << [method, payload]
|
@@ -110,9 +113,9 @@ module Cocaine
|
|
110
113
|
class RxChannel
|
111
114
|
attr_reader :tx, :rx
|
112
115
|
|
113
|
-
def initialize(tree)
|
116
|
+
def initialize(tree, session, &block)
|
114
117
|
queue = Celluloid::Mailbox.new
|
115
|
-
@tx = TxMailbox.new queue, tree
|
118
|
+
@tx = TxMailbox.new queue, tree, session, &block
|
116
119
|
@rx = RxMailbox.new queue
|
117
120
|
end
|
118
121
|
end
|
@@ -160,6 +163,9 @@ module Cocaine
|
|
160
163
|
end
|
161
164
|
end
|
162
165
|
|
166
|
+
class ServiceError < IOError
|
167
|
+
end
|
168
|
+
|
163
169
|
# [Detail]
|
164
170
|
# Service actor, which can define itself via its dispatch tree.
|
165
171
|
class DefinedService < Meta
|
@@ -222,7 +228,10 @@ module Cocaine
|
|
222
228
|
LOG.debug "Invoking #{@name}[#{id}=#{method}] with #{args}"
|
223
229
|
|
224
230
|
txchan = TxChannel.new txtree, @counter, @socket
|
225
|
-
rxchan = RxChannel.new rxtree
|
231
|
+
rxchan = RxChannel.new rxtree, @counter do |session|
|
232
|
+
@sessions.delete session
|
233
|
+
end
|
234
|
+
|
226
235
|
@sessions[@counter] = [txchan, rxchan.tx]
|
227
236
|
|
228
237
|
LOG.debug "<- [#{@counter}, #{id}, #{args}]"
|
@@ -241,17 +250,14 @@ module Cocaine
|
|
241
250
|
end
|
242
251
|
end
|
243
252
|
|
244
|
-
class ServiceError < IOError
|
245
|
-
end
|
246
|
-
|
247
253
|
# [API]
|
248
254
|
# Service class. All you need is name and (optionally) locator endpoint.
|
249
255
|
class Service < DefinedService
|
250
256
|
def initialize(name, host=nil, port=nil)
|
251
257
|
locator = Locator.new host, port
|
252
258
|
tx, rx = locator.resolve name
|
253
|
-
|
254
|
-
if
|
259
|
+
id, payload = rx.recv
|
260
|
+
if id == :error
|
255
261
|
raise ServiceError.new payload
|
256
262
|
end
|
257
263
|
|
@@ -351,7 +357,9 @@ module Cocaine
|
|
351
357
|
def invoke(session, event)
|
352
358
|
actor = @actors[event]
|
353
359
|
txchan = TxChannel.new RPC::TXTREE, session, @socket
|
354
|
-
rxchan = RxChannel.new RPC::RXTREE
|
360
|
+
rxchan = RxChannel.new RPC::RXTREE, session do |session_|
|
361
|
+
@sessions.delete session_
|
362
|
+
end
|
355
363
|
|
356
364
|
if actor
|
357
365
|
@sessions[session] = [txchan, rxchan.tx]
|
data/lib/cocaine/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocaine-framework
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.12.0.pre.
|
4
|
+
version: 0.12.0.pre.rc10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evgeny Safronov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -24,6 +24,34 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.7'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.7'
|
27
55
|
- !ruby/object:Gem::Dependency
|
28
56
|
name: msgpack
|
29
57
|
requirement: !ruby/object:Gem::Requirement
|