anycable 0.6.1 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +49 -2
  3. data/bin/anycable +1 -1
  4. data/bin/anycabled +30 -0
  5. data/lib/anycable/broadcast_adapters/redis.rb +1 -1
  6. data/lib/anycable/cli.rb +1 -1
  7. data/lib/anycable/config.rb +4 -2
  8. data/lib/anycable/exceptions_handling.rb +9 -3
  9. data/lib/anycable/rpc_handler.rb +27 -4
  10. data/lib/anycable/server.rb +22 -6
  11. data/lib/anycable/version.rb +1 -1
  12. metadata +7 -56
  13. data/.github/ISSUE_TEMPLATE.md +0 -25
  14. data/.github/PULL_REQUEST_TEMPLATE.md +0 -31
  15. data/.gitignore +0 -40
  16. data/.hound.yml +0 -3
  17. data/.rubocop.yml +0 -71
  18. data/.travis.yml +0 -16
  19. data/Gemfile +0 -8
  20. data/Makefile +0 -5
  21. data/PITCHME.md +0 -139
  22. data/PITCHME.yaml +0 -1
  23. data/Rakefile +0 -8
  24. data/anycable.gemspec +0 -35
  25. data/assets/Memory3.png +0 -0
  26. data/assets/Memory5.png +0 -0
  27. data/assets/RTT3.png +0 -0
  28. data/assets/RTT5.png +0 -0
  29. data/assets/Scheme1.png +0 -0
  30. data/assets/Scheme2.png +0 -0
  31. data/assets/cpu_chart.gif +0 -0
  32. data/assets/cpu_chart2.gif +0 -0
  33. data/assets/evlms.png +0 -0
  34. data/benchmarks/.gitignore +0 -2
  35. data/benchmarks/2017-02-12.md +0 -308
  36. data/benchmarks/2018-03-04.md +0 -192
  37. data/benchmarks/2018-05-27-rpc-bench.md +0 -57
  38. data/benchmarks/2018-10-27.md +0 -181
  39. data/benchmarks/HowTo.md +0 -23
  40. data/benchmarks/ansible.cfg +0 -9
  41. data/benchmarks/assets/2018-10-27-action-cable-rss.png +0 -0
  42. data/benchmarks/assets/2018-10-27-action-cable-rtt.png +0 -0
  43. data/benchmarks/assets/2018-10-27-anycable-rss.png +0 -0
  44. data/benchmarks/assets/2018-10-27-anycable-rtt.png +0 -0
  45. data/benchmarks/assets/2018-10-27-async-rss.png +0 -0
  46. data/benchmarks/assets/2018-10-27-async-rtt.png +0 -0
  47. data/benchmarks/assets/2018-10-27-falcon-cable-rss.png +0 -0
  48. data/benchmarks/assets/2018-10-27-falcon-cable-rtt.png +0 -0
  49. data/benchmarks/assets/2018-10-27-iodine-cable-rss.png +0 -0
  50. data/benchmarks/assets/2018-10-27-iodine-cable-rtt.png +0 -0
  51. data/benchmarks/assets/2018-10-27-plezi-rss.png +0 -0
  52. data/benchmarks/assets/2018-10-27-plezi-rtt.png +0 -0
  53. data/benchmarks/bench.png +0 -0
  54. data/benchmarks/benchmark.yml +0 -69
  55. data/benchmarks/hosts +0 -5
  56. data/benchmarks/rtt_plot.py +0 -74
  57. data/benchmarks/rtt_plot_test.py +0 -16
  58. data/benchmarks/servers.yml +0 -58
  59. data/circle.yml +0 -8
  60. data/etc/bug_report_template.rb +0 -76
  61. data/lib/anycable/handler/capture_exceptions.rb +0 -39
  62. data/protos/rpc.proto +0 -55
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cff0f2d872c485fc15f3046b2fdacbb9cfce2d3e7e312b8f0461dc20f2e52a41
4
- data.tar.gz: 586fe6c97d6063512020bde66aaf3a0d8c2dc4a33ca508beb67295a18f121618
3
+ metadata.gz: 982192dbe84e0576b13033aadf3ead0238e28bf4c30b6dec2d08228cd2093f3c
4
+ data.tar.gz: 9af924544238340e0c5b171a738b9bec99ebe25c13cc398d279318f6c9cbef12
5
5
  SHA512:
6
- metadata.gz: f055860a0a5a10eb3954bc6dd5088e66cc948eefe3b853a6fee63ea9ed5e7fafa2827e4fda6f67eeca3efe6efccc2d69eb59f6e8ee11d969be4ef027e73727a8
7
- data.tar.gz: c53d21ea1beb3443451839ceb69e318c840b04564e35379adebd65ccfc4f708666c8c78514a805f16e564508aa190ad81a27329334826016f2bc08bc5aa16fde
6
+ metadata.gz: ba03a684ddce90df929c469deb4b219a494578ab9c203321e9c9f900810f98132eb74d8fc16aa1b79c6042c28bd5b3da2ac83d39bd4e25944127191dc4b2f8b7
7
+ data.tar.gz: 77a874ad448dff0cca9d8ada4259c8c48ab4fdb87d1df1f3c6bee1dab50f23335f1fc390ee60fb96483a89cc0071700945bdffa73f908745987de2c2e7877c91
@@ -2,6 +2,53 @@
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
+
11
+ ## 0.6.2 (2019-03-15)
12
+
13
+ - Add GRPC service method name and message content to exception notifications ([@sponomarev][])
14
+
15
+ `Anycable.capture_exception` allows accessing GRPC service method name and message content
16
+ on which an exception was captured. It can be used for exceptions grouping in your tracker and
17
+ providing additional data to investigate a root of a problem.
18
+
19
+ Example:
20
+
21
+ ```ruby
22
+ AnyCable.capture_exception do |ex, method, message|
23
+ Honeybadger.notify(ex, component: "any_cable", action: method, params: message)
24
+ end
25
+ ```
26
+
27
+ Usage of a handler proc with just a single argument is preserved for the sake of compatibility.
28
+
29
+ - Add deprecation warning to default host usage ([@sponomarev][])
30
+
31
+ Exposing AnyCable publicly is considered to be harmful and planned to be changed
32
+ in future versions.
33
+
34
+ - Allow running the server as a detachable daemon ([@sponomarev][])
35
+
36
+ Server is fully managed by the binary itself.
37
+
38
+ ```
39
+ # Start anycable daemon
40
+ $ bundle exec anycabled start
41
+
42
+ # Pass cli options to anycable through daemon. Separate daemon options and anycable options with `--`
43
+ $ bundle exec anycabled start -- --rpc-host 127.0.0.1:31337
44
+
45
+ # Stop anycable daemon
46
+ $ bundle exec anycabled stop
47
+
48
+ # See more anycable daemon options
49
+ $ bundle exec anycabled
50
+ ```
51
+
5
52
  ## 0.6.1 (2019-01-05)
6
53
 
7
54
  - [Fix #63](https://github.com/anycable/anycable-rails/issues/63) Load `anyway_config` after application boot to make sure that all frameworks dependent functionality is loaded. ([@palkan][])
@@ -116,7 +163,7 @@ Minor fixes.
116
163
 
117
164
  - [#28](https://github.com/anycable/anycable/issues/28) Support arbitrary headers. ([@palkan][])
118
165
 
119
- Previously we hardcoded only "Cookie" header. Now we add all passed headers by WebSocket server to request env.
166
+ Previously we hardcoded only "Cookie" header. Now we add all passed headers by WebSocket server to request env.
120
167
 
121
168
  - [#27](https://github.com/anycable/anycable/issues/27) Add `error_msg` to RPC responses. ([@palkan][])
122
169
 
@@ -130,7 +177,7 @@ We provide `error_msg` only when request status is `ERROR`.
130
177
 
131
178
  - [#25](https://github.com/anycable/anycable/issues/25) Improve logging and exceptions handling. ([@palkan][])
132
179
 
133
- Default logger logs to STDOUT with `info` level by default but can be configured to log to file with
180
+ Default logger logs to STDOUT with `info` level by default but can be configured to log to file with
134
181
  any severity.
135
182
 
136
183
  GRPC logging is turned off by default (can be turned on through `log_grpc` configuration parameter).
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require_relative "../lib/anycable/cli"
3
+ require "anycable/cli"
4
4
 
5
5
  begin
6
6
  cli = AnyCable::CLI.new
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "anycable/cli"
4
+
5
+ begin
6
+ require "daemons"
7
+ rescue LoadError
8
+ raise <<~MSG
9
+ You need to add gem 'daemons' to your Gemfile if you want to use `anycabled`:
10
+
11
+ # Gemfile
12
+ gem "daemons", "~> 1.3", require: false
13
+ MSG
14
+ end
15
+
16
+ options = {
17
+ dir: "tmp/pids",
18
+ log_output: false
19
+ }
20
+
21
+ # Preserve current directory. We need it inside the server.
22
+ current_dir = Dir.pwd
23
+
24
+ # Clean ARGV from daemon command and args
25
+ _, _, args = Daemons::Controller.split_argv(ARGV)
26
+
27
+ Daemons.run_proc("anycable", options) do
28
+ Dir.chdir current_dir
29
+ AnyCable::CLI.new.run(args)
30
+ end
@@ -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"
@@ -23,7 +23,7 @@ module AnyCable
23
23
  attr_reader :server, :health_server
24
24
 
25
25
  # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
26
- def run(args)
26
+ def run(args = {})
27
27
  @at_stop = []
28
28
 
29
29
  extra_options = parse_cli_options!(args)
@@ -8,10 +8,12 @@ module AnyCable
8
8
  class Config < Anyway::Config
9
9
  config_name :anycable
10
10
 
11
+ DefaultHostWrapper = Class.new(String)
12
+
11
13
  attr_config(
12
14
  ### gRPC options
13
- rpc_host: "[::]:50051",
14
- # For defaults see https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/generic/rpc_server.rb#L162-L170
15
+ rpc_host: DefaultHostWrapper.new("[::]:50051"),
16
+ # For defaults see https://github.com/grpc/grpc/blob/51f0d35509bcdaba572d422c4f856208162022de/src/ruby/lib/grpc/generic/rpc_server.rb#L186-L216
15
17
  rpc_pool_size: GRPC::RpcServer::DEFAULT_POOL_SIZE,
16
18
  rpc_max_waiting_requests: GRPC::RpcServer::DEFAULT_MAX_WAITING_REQUESTS,
17
19
  rpc_poll_period: GRPC::RpcServer::DEFAULT_POLL_PERIOD,
@@ -4,15 +4,15 @@ module AnyCable
4
4
  module ExceptionsHandling # :nodoc:
5
5
  class << self
6
6
  def add_handler(block)
7
- handlers << block
7
+ handlers << procify(block)
8
8
  end
9
9
 
10
10
  alias << add_handler
11
11
 
12
- def notify(exp)
12
+ def notify(exp, method_name, message)
13
13
  handlers.each do |handler|
14
14
  begin
15
- handler.call(exp)
15
+ handler.call(exp, method_name, message)
16
16
  rescue StandardError => exp
17
17
  AnyCable.logger.error "!!! EXCEPTION HANDLER THREW AN ERROR !!!"
18
18
  AnyCable.logger.error exp
@@ -23,6 +23,12 @@ module AnyCable
23
23
 
24
24
  private
25
25
 
26
+ def procify(block)
27
+ return block unless block.lambda?
28
+
29
+ proc { |*args| block.call(*args.take(block.arity)) }
30
+ end
31
+
26
32
  def handlers
27
33
  @handlers ||= []
28
34
  end
@@ -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
@@ -12,8 +12,8 @@ module AnyCable
12
12
  #
13
13
  # Basic example:
14
14
  #
15
- # # create new server listening on [::]:50051 (default host)
16
- # server = AnyCable::Server.new(host: "[::]:50051")
15
+ # # create new server listening on the loopback interface with 50051 port
16
+ # server = AnyCable::Server.new(host: "127.0.0.1:50051")
17
17
  #
18
18
  # # run gRPC server in bakground
19
19
  # server.start
@@ -25,7 +25,7 @@ module AnyCable
25
25
  # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
26
26
  def start(**options)
27
27
  warn <<~DEPRECATION
28
- Using AnyCable::Server.start is deprecated!
28
+ DEPRECATION WARNING: Using AnyCable::Server.start is deprecated!
29
29
  Please, use anycable CLI instead.
30
30
 
31
31
  See https://docs.anycable.io/#upgrade_to_0_6_0
@@ -63,11 +63,9 @@ module AnyCable
63
63
  # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
64
64
  end
65
65
 
66
- DEFAULT_HOST = "0.0.0.0:50051"
67
-
68
66
  attr_reader :grpc_server, :host
69
67
 
70
- def initialize(host: DEFAULT_HOST, logger: AnyCable.logger, **options)
68
+ def initialize(host:, logger: AnyCable.logger, **options)
71
69
  @logger = logger
72
70
  @host = host
73
71
  @grpc_server = build_server(options)
@@ -80,6 +78,8 @@ module AnyCable
80
78
 
81
79
  raise "Cannot re-start stopped server" if stopped?
82
80
 
81
+ check_default_host
82
+
83
83
  logger.info "RPC server is starting..."
84
84
 
85
85
  @start_thread = Thread.new { grpc_server.run }
@@ -132,5 +132,21 @@ module AnyCable
132
132
  )
133
133
  health_checker
134
134
  end
135
+
136
+ def check_default_host
137
+ return unless host.is_a?(Anycable::Config::DefaultHostWrapper)
138
+
139
+ warn <<~DEPRECATION
140
+ DEPRECATION WARNING: You're using default rpc_host configuration which starts AnyCable RPC
141
+ server on all available interfaces including external IPv4 and IPv6.
142
+ This is about to be changed to loopback interface only in future versions.
143
+
144
+ Please, consider switching to the loopback interface or set "[::]:50051"
145
+ explicitly in your configuration, if you want to continue with the current
146
+ behavior and supress this message.
147
+
148
+ See https://docs.anycable.io/#/configuration
149
+ DEPRECATION
150
+ end
135
151
  end
136
152
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AnyCable
4
- VERSION = "0.6.1"
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.1
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-01-06 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
@@ -155,70 +155,23 @@ email:
155
155
  - dementiev.vm@gmail.com
156
156
  executables:
157
157
  - anycable
158
+ - anycabled
158
159
  extensions: []
159
160
  extra_rdoc_files: []
160
161
  files:
161
- - ".github/ISSUE_TEMPLATE.md"
162
- - ".github/PULL_REQUEST_TEMPLATE.md"
163
- - ".gitignore"
164
- - ".hound.yml"
165
- - ".rubocop.yml"
166
- - ".travis.yml"
167
162
  - CHANGELOG.md
168
- - Gemfile
169
163
  - MIT-LICENSE
170
- - Makefile
171
- - PITCHME.md
172
- - PITCHME.yaml
173
164
  - README.md
174
- - Rakefile
175
- - anycable.gemspec
176
- - assets/Memory3.png
177
- - assets/Memory5.png
178
- - assets/RTT3.png
179
- - assets/RTT5.png
180
- - assets/Scheme1.png
181
- - assets/Scheme2.png
182
- - assets/cpu_chart.gif
183
- - assets/cpu_chart2.gif
184
- - assets/evlms.png
185
- - benchmarks/.gitignore
186
- - benchmarks/2017-02-12.md
187
- - benchmarks/2018-03-04.md
188
- - benchmarks/2018-05-27-rpc-bench.md
189
- - benchmarks/2018-10-27.md
190
- - benchmarks/HowTo.md
191
- - benchmarks/ansible.cfg
192
- - benchmarks/assets/2018-10-27-action-cable-rss.png
193
- - benchmarks/assets/2018-10-27-action-cable-rtt.png
194
- - benchmarks/assets/2018-10-27-anycable-rss.png
195
- - benchmarks/assets/2018-10-27-anycable-rtt.png
196
- - benchmarks/assets/2018-10-27-async-rss.png
197
- - benchmarks/assets/2018-10-27-async-rtt.png
198
- - benchmarks/assets/2018-10-27-falcon-cable-rss.png
199
- - benchmarks/assets/2018-10-27-falcon-cable-rtt.png
200
- - benchmarks/assets/2018-10-27-iodine-cable-rss.png
201
- - benchmarks/assets/2018-10-27-iodine-cable-rtt.png
202
- - benchmarks/assets/2018-10-27-plezi-rss.png
203
- - benchmarks/assets/2018-10-27-plezi-rtt.png
204
- - benchmarks/bench.png
205
- - benchmarks/benchmark.yml
206
- - benchmarks/hosts
207
- - benchmarks/rtt_plot.py
208
- - benchmarks/rtt_plot_test.py
209
- - benchmarks/servers.yml
210
165
  - bin/anycable
166
+ - bin/anycabled
211
167
  - bin/console
212
168
  - bin/setup
213
- - circle.yml
214
- - etc/bug_report_template.rb
215
169
  - lib/anycable.rb
216
170
  - lib/anycable/broadcast_adapters.rb
217
171
  - lib/anycable/broadcast_adapters/redis.rb
218
172
  - lib/anycable/cli.rb
219
173
  - lib/anycable/config.rb
220
174
  - lib/anycable/exceptions_handling.rb
221
- - lib/anycable/handler/capture_exceptions.rb
222
175
  - lib/anycable/health_server.rb
223
176
  - lib/anycable/middleware.rb
224
177
  - lib/anycable/middleware_chain.rb
@@ -228,7 +181,6 @@ files:
228
181
  - lib/anycable/server.rb
229
182
  - lib/anycable/socket.rb
230
183
  - lib/anycable/version.rb
231
- - protos/rpc.proto
232
184
  homepage: http://github.com/anycable/anycable
233
185
  licenses:
234
186
  - MIT
@@ -248,8 +200,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
248
200
  - !ruby/object:Gem::Version
249
201
  version: '0'
250
202
  requirements: []
251
- rubyforge_project:
252
- rubygems_version: 2.7.6
203
+ rubygems_version: 3.0.2
253
204
  signing_key:
254
205
  specification_version: 4
255
206
  summary: AnyCable is a polyglot replacement for ActionCable-compatible servers