pipe_rpc 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pipe_rpc/client_request_error_response.rb +1 -3
- data/lib/pipe_rpc/error.rb +7 -5
- data/lib/pipe_rpc/hub_message.rb +16 -8
- data/lib/pipe_rpc/hub_requests.rb +5 -3
- data/lib/pipe_rpc/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d754a16c8369ffd2cfbeda827a6ec49028326c21
|
4
|
+
data.tar.gz: 20c0a704f6f64b13f2a2a661bec384c3f8d117d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 340cdcba3e23c86ecaba149671f948e27a73e27f97737c3e03507ac9ff8b49b678341270b5e0f2f2529257bcc2cf1f3bcf16b62a02a9708bd13c05f2db99695e
|
7
|
+
data.tar.gz: 526a134f5533eda00100d4459ef8885688a3a581cb518515ceb7d5e7e0608f3f1888ca1aadd08738718ff935d830c375561d8a5eb2745f6b17a4e6ee65b5b35e
|
@@ -21,9 +21,7 @@ module PipeRpc
|
|
21
21
|
private
|
22
22
|
|
23
23
|
def no_method_error
|
24
|
-
method
|
25
|
-
args = @data.fetch(:args)
|
26
|
-
NoMethodError.new("undefined method `#{method}' for <Client:#{@request.server}>", method, args)
|
24
|
+
NoMethodError.new("undefined method `#{@data.fetch(:method)}' for <Client:#{@request.server}>")
|
27
25
|
end
|
28
26
|
|
29
27
|
def argument_error
|
data/lib/pipe_rpc/error.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module PipeRpc
|
2
|
-
class Error <
|
2
|
+
class Error < StandardError; end
|
3
3
|
class ClosedError < Error; end
|
4
4
|
class UnknownError < Error; end
|
5
5
|
|
@@ -7,8 +7,10 @@ module PipeRpc
|
|
7
7
|
class MessageParseError < MessageError; end
|
8
8
|
class InvalidMessageError < MessageError; end
|
9
9
|
|
10
|
-
class
|
11
|
-
class
|
12
|
-
class
|
13
|
-
class
|
10
|
+
class EvaluationError < Error; end
|
11
|
+
class NoMethodError < EvaluationError; end
|
12
|
+
class ArgumentError < EvaluationError; end
|
13
|
+
class InternalError < EvaluationError; end
|
14
|
+
class NoServerError < EvaluationError; end
|
15
|
+
class ReflectedError < EvaluationError; end
|
14
16
|
end
|
data/lib/pipe_rpc/hub_message.rb
CHANGED
@@ -18,6 +18,16 @@ module PipeRpc
|
|
18
18
|
@body.has_key? :error and @body[:id].nil?
|
19
19
|
end
|
20
20
|
|
21
|
+
def handle
|
22
|
+
if response?
|
23
|
+
guarded{ handler.handle if handler }
|
24
|
+
else
|
25
|
+
handler.handle if handler
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
21
31
|
def handler_type
|
22
32
|
if request?
|
23
33
|
Hub::Request
|
@@ -31,18 +41,16 @@ module PipeRpc
|
|
31
41
|
end
|
32
42
|
|
33
43
|
def handler
|
34
|
-
handler_type.new(@hub, @body)
|
44
|
+
@handler ||= guarded{ handler_type.new(@hub, @body) }
|
45
|
+
end
|
46
|
+
|
47
|
+
def guarded
|
48
|
+
yield
|
35
49
|
rescue => e
|
36
|
-
@hub.socket.write ErrorResponse.new(id: @body[:id], error: { code: -32600,
|
50
|
+
@hub.socket.write PipeRpc::ErrorResponse.new(id: @body[:id], error: { code: -32600,
|
37
51
|
data: { message: e.message } })
|
38
52
|
nil
|
39
53
|
end
|
40
|
-
|
41
|
-
def handle
|
42
|
-
handler.tap do |handler|
|
43
|
-
handler.handle if handler
|
44
|
-
end
|
45
|
-
end
|
46
54
|
end
|
47
55
|
end
|
48
56
|
end
|
@@ -23,9 +23,11 @@ module PipeRpc
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def inject_result_for(id, result)
|
26
|
-
request = @requests.delete(id)
|
27
|
-
|
28
|
-
|
26
|
+
if request = @requests.delete(id)
|
27
|
+
request.result.value = result
|
28
|
+
else
|
29
|
+
raise "no request with id '#{id.inspect}'"
|
30
|
+
end
|
29
31
|
end
|
30
32
|
|
31
33
|
def wait_for_results_through(iteration)
|
data/lib/pipe_rpc/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pipe_rpc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christopher Aue
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|