carrot_rpc 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7021e60c18d67242d796d0a7989d0b6ba411bd2f
4
- data.tar.gz: 2a857193768aafda74326c94339132e71d30ba65
3
+ metadata.gz: d9202e93b42d441f3781fef272d5957cfab7ea4a
4
+ data.tar.gz: 91e6cc50e86d52b94693bacf40a45ba13a17c70d
5
5
  SHA512:
6
- metadata.gz: d244349b6f223b3bc3104075a766084054d7e15aab8d419c7e2a0c12c8cc63ac9b2554366ad56975dff3972463d40867aaa1a931c608a661695e25f6c358168f
7
- data.tar.gz: 3f74c94e6af796112817eb92de1401767e837fe06ee4d9356473cffabdecb8ce8e896a16f86c3c74d007cd3f1fab899c8bbcca9a8f0f4f020031a6f35f60f248
6
+ metadata.gz: 6020b67ed40ebdee85b960f2254cdedceca9d93cc289e0c5900f7ab10f3ec9a77d5b9c8a64274c2530f94fd6263ef2703cc808398ea1819db23668dc1c6101fd
7
+ data.tar.gz: b001fd637d344818920319b27b1ddc51dda764f5a2335d037864a6f36687eee030ee411c2238ee31324b015e1fe23fa0192322fe6f10f7691df663f30a8a5a8d
data/CHANGELOG.md CHANGED
@@ -3,38 +3,48 @@
3
3
  **Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
4
4
 
5
5
  - [Changelog](#changelog)
6
- - [v0.4.1](#v041)
6
+ - [v0.5.1](#v051)
7
7
  - [Bug Fixes](#bug-fixes)
8
- - [v0.4.0](#v040)
8
+ - [v0.5.0](#v050)
9
9
  - [Enhancements](#enhancements)
10
+ - [Incompatible Changes](#incompatible-changes)
11
+ - [v0.4.1](#v041)
10
12
  - [Bug Fixes](#bug-fixes-1)
11
- - [v0.3.0](#v030)
13
+ - [v0.4.0](#v040)
12
14
  - [Enhancements](#enhancements-1)
13
15
  - [Bug Fixes](#bug-fixes-2)
14
- - [v0.2.3](#v023)
16
+ - [Incompatible Changes](#incompatible-changes-1)
17
+ - [v0.3.0](#v030)
15
18
  - [Enhancements](#enhancements-2)
16
19
  - [Bug Fixes](#bug-fixes-3)
20
+ - [v0.2.3](#v023)
21
+ - [Enhancements](#enhancements-3)
22
+ - [Bug Fixes](#bug-fixes-4)
17
23
  - [Upgrading](#upgrading)
18
24
  - [v0.2.1](#v021)
19
- - [Bug Fixes](#bug-fixes-4)
20
- - [v0.2.0](#v020)
21
- - [Enhancements](#enhancements-3)
22
25
  - [Bug Fixes](#bug-fixes-5)
23
- - [Incompatible Changes](#incompatible-changes)
24
- - [v0.1.2](#v012)
26
+ - [v0.2.0](#v020)
25
27
  - [Enhancements](#enhancements-4)
26
28
  - [Bug Fixes](#bug-fixes-6)
27
- - [v0.1.1](#v011)
29
+ - [Incompatible Changes](#incompatible-changes-2)
30
+ - [v0.1.2](#v012)
28
31
  - [Enhancements](#enhancements-5)
29
32
  - [Bug Fixes](#bug-fixes-7)
30
- - [Incompatible Changes](#incompatible-changes-1)
33
+ - [v0.1.1](#v011)
34
+ - [Enhancements](#enhancements-6)
35
+ - [Bug Fixes](#bug-fixes-8)
36
+ - [Incompatible Changes](#incompatible-changes-3)
31
37
 
32
38
  <!-- END doctoc generated TOC please keep comment here to allow auto update -->
33
39
 
34
40
  # Changelog
35
41
  All significant changes in the project are documented here.
36
42
 
37
- ## v.0.5.0
43
+ ## v0.5.1
44
+ ### Bug Fixes
45
+ * [#31](https://github.com/C-S-D/carrot_rpc/pull/31) - If the server does not respond to a method in the `request_message`, then return a "Method not found" JSONRPC 2.0 error instead of the server crashing with `NoMethodError` exception. - [KronicDeth)(https://github.com/KronicDeth)
46
+
47
+ ## v0.5.0
38
48
  ### Enhancements
39
49
  * [#25](https://github.com/C-S-D/carrot_rpc/pull/25) - [shamil614](https://github.com/shamil614)
40
50
  * Timeout RpcClient requests when response is not received.
data/README.md CHANGED
@@ -10,6 +10,7 @@
10
10
  - [Usage](#usage)
11
11
  - [Writing Servers](#writing-servers)
12
12
  - [Writing Clients](#writing-clients)
13
+ - [Support for JSONAPI::Resources](#support-for-jsonapiresources)
13
14
  - [Development](#development)
14
15
  - [Contributing](#contributing)
15
16
 
@@ -34,7 +34,24 @@ class CarrotRpc::RpcServer
34
34
  end
35
35
 
36
36
  def process_request(request_message, properties:)
37
- result = send(request_message[:method], request_message[:params])
37
+ method = request_message[:method]
38
+
39
+ handler = if respond_to? method
40
+ :call_found_method
41
+ else
42
+ :reply_method_not_found
43
+ end
44
+
45
+ send handler,
46
+ method: method,
47
+ properties: properties,
48
+ request_message: request_message
49
+ end
50
+
51
+ private
52
+
53
+ def call_found_method(method:, properties:, request_message:)
54
+ result = send(method, request_message[:params])
38
55
  rescue CarrotRpc::Error => rpc_server_error
39
56
  logger.error(rpc_server_error)
40
57
 
@@ -47,8 +64,6 @@ class CarrotRpc::RpcServer
47
64
  request_message: request_message
48
65
  end
49
66
 
50
- private
51
-
52
67
  def reply(properties:, response_message:)
53
68
  @exchange.publish response_message.to_json,
54
69
  correlation_id: properties.correlation_id,
@@ -65,6 +80,19 @@ class CarrotRpc::RpcServer
65
80
  response_message: response_message
66
81
  end
67
82
 
83
+ def reply_method_not_found(method:, properties:, request_message:)
84
+ error = CarrotRpc::Error.new code: CarrotRpc::Error::Code::METHOD_NOT_FOUND,
85
+ data: {
86
+ method: method
87
+ },
88
+ message: "Method not found"
89
+ logger.error(error)
90
+
91
+ reply_error error.serialized_message,
92
+ properties: properties,
93
+ request_message: request_message
94
+ end
95
+
68
96
  # See http://www.jsonrpc.org/specification#response_object
69
97
  def reply_result(result, properties:, request_message:)
70
98
  if result && result.is_a?(Hash) && result["errors"]
@@ -1,3 +1,3 @@
1
1
  module CarrotRpc
2
- VERSION = "0.5.0".freeze
2
+ VERSION = "0.5.1".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carrot_rpc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Hamilton
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-05-02 00:00:00.000000000 Z
12
+ date: 2016-05-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport