anycable 0.6.2 → 0.6.3

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
  SHA256:
3
- metadata.gz: 9044b4ce81ea84415ac896ea46c96ad55da523edc3251aa07d7e2490c3a4745e
4
- data.tar.gz: 1bfe649fe5bfac2276496668f7fa3e588f38a6c1b0e603d16a3b3695f08a8363
3
+ metadata.gz: 982192dbe84e0576b13033aadf3ead0238e28bf4c30b6dec2d08228cd2093f3c
4
+ data.tar.gz: 9af924544238340e0c5b171a738b9bec99ebe25c13cc398d279318f6c9cbef12
5
5
  SHA512:
6
- metadata.gz: 415117187f998d7704e9a2d1a305b0fb8cc55b2cdaf58a37292043675bc499e32b806cd2a5a574210f54f16ea91fa7f072cc87d37afec860f13c1abbc9978813
7
- data.tar.gz: 5ed3809fe24065e2d029e4cfd92f794112ed1b08cf3ed312e56f5a97cd5e23b51be4f9425303e55b18d9cb41d9143ce639ab60556c34511746994ba9c4d78027
6
+ metadata.gz: ba03a684ddce90df929c469deb4b219a494578ab9c203321e9c9f900810f98132eb74d8fc16aa1b79c6042c28bd5b3da2ac83d39bd4e25944127191dc4b2f8b7
7
+ data.tar.gz: 77a874ad448dff0cca9d8ada4259c8c48ab4fdb87d1df1f3c6bee1dab50f23335f1fc390ee60fb96483a89cc0071700945bdffa73f908745987de2c2e7877c91
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 0.6.3 (2019-03-26)
6
+
7
+ - Relax `redis` gem version requirement. ([@palkan][])
8
+
9
+ Use the same restriction as Action Cable does (`>= 3`).
10
+
5
11
  ## 0.6.2 (2019-03-15)
6
12
 
7
13
  - Add GRPC service method name and message content to exception notifications ([@sponomarev][])
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- gem "redis", ">= 4.0"
3
+ gem "redis", ">= 3"
4
4
 
5
5
  require "redis"
6
6
  require "json"
@@ -4,15 +4,12 @@ require "anycable/socket"
4
4
  require "anycable/rpc/rpc_pb"
5
5
  require "anycable/rpc/rpc_services_pb"
6
6
 
7
- require "anycable/handler/capture_exceptions"
8
-
9
7
  # rubocop:disable Metrics/AbcSize
10
8
  # rubocop:disable Metrics/MethodLength
9
+ # rubocop:disable Metrics/ClassLength
11
10
  module AnyCable
12
11
  # RPC service handler
13
12
  class RPCHandler < AnyCable::RPC::Service
14
- prepend AnyCable::Handler::CaptureExceptions
15
-
16
13
  # Handle connection request from WebSocket server
17
14
  def connect(request, _unused_call)
18
15
  logger.debug("RPC Connect: #{request.inspect}")
@@ -32,6 +29,13 @@ module AnyCable
32
29
  transmissions: socket.transmissions
33
30
  )
34
31
  end
32
+ rescue StandardError => exp
33
+ notify_exception(exp, :connect, request)
34
+
35
+ AnyCable::ConnectionResponse.new(
36
+ status: AnyCable::Status::ERROR,
37
+ error_msg: exp.message
38
+ )
35
39
  end
36
40
 
37
41
  def disconnect(request, _unused_call)
@@ -50,6 +54,13 @@ module AnyCable
50
54
  else
51
55
  AnyCable::DisconnectResponse.new(status: AnyCable::Status::FAILURE)
52
56
  end
57
+ rescue StandardError => exp
58
+ notify_exception(exp, :disconnect, request)
59
+
60
+ AnyCable::DisconnectResponse.new(
61
+ status: AnyCable::Status::ERROR,
62
+ error_msg: exp.message
63
+ )
53
64
  end
54
65
 
55
66
  def command(message, _unused_call)
@@ -75,6 +86,13 @@ module AnyCable
75
86
  streams: socket.streams,
76
87
  transmissions: socket.transmissions
77
88
  )
89
+ rescue StandardError => exp
90
+ notify_exception(exp, :command, message)
91
+
92
+ AnyCable::CommandResponse.new(
93
+ status: AnyCable::Status::ERROR,
94
+ error_msg: exp.message
95
+ )
78
96
  end
79
97
 
80
98
  private
@@ -114,7 +132,12 @@ module AnyCable
114
132
  def factory
115
133
  AnyCable.connection_factory
116
134
  end
135
+
136
+ def notify_exception(exp, method_name, message)
137
+ AnyCable::ExceptionsHandling.notify(exp, method_name.to_s, message.to_h)
138
+ end
117
139
  end
118
140
  end
119
141
  # rubocop:enable Metrics/AbcSize
120
142
  # rubocop:enable Metrics/MethodLength
143
+ # rubocop:enable Metrics/ClassLength
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AnyCable
4
- VERSION = "0.6.2"
4
+ VERSION = "0.6.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anycable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - palkan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-15 00:00:00.000000000 Z
11
+ date: 2019-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: anyway_config
@@ -114,14 +114,14 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 0.60.0
117
+ version: 0.65.0
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 0.60.0
124
+ version: 0.65.0
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: simplecov
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -172,7 +172,6 @@ files:
172
172
  - lib/anycable/cli.rb
173
173
  - lib/anycable/config.rb
174
174
  - lib/anycable/exceptions_handling.rb
175
- - lib/anycable/handler/capture_exceptions.rb
176
175
  - lib/anycable/health_server.rb
177
176
  - lib/anycable/middleware.rb
178
177
  - lib/anycable/middleware_chain.rb
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "anycable/rpc/rpc_pb"
4
-
5
- module AnyCable
6
- module Handler # :nodoc:
7
- # Handle app-level errors.
8
- #
9
- # NOTE: this functionality couldn't be implemeted
10
- # as middleware, 'cause interceptors do not support
11
- # aborting the call and returning a data
12
- module CaptureExceptions
13
- RESPONSE_CLASS = {
14
- command: AnyCable::CommandResponse,
15
- connect: AnyCable::ConnectionResponse,
16
- disconnect: AnyCable::DisconnectResponse
17
- }.freeze
18
-
19
- RESPONSE_CLASS.keys.each do |mid|
20
- module_eval <<~CODE, __FILE__, __LINE__ + 1
21
- def #{mid}(message, *)
22
- capture_exceptions(:#{mid}, message) { super }
23
- end
24
- CODE
25
- end
26
-
27
- def capture_exceptions(method_name, message)
28
- yield
29
- rescue StandardError => exp
30
- AnyCable::ExceptionsHandling.notify(exp, method_name.to_s, message.to_h)
31
-
32
- RESPONSE_CLASS.fetch(method_name).new(
33
- status: AnyCable::Status::ERROR,
34
- error_msg: exp.message
35
- )
36
- end
37
- end
38
- end
39
- end