anycable-rails 1.0.0.preview2 → 1.0.0

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.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +28 -122
  3. data/README.md +14 -34
  4. data/lib/anycable/rails.rb +36 -2
  5. data/lib/anycable/rails/actioncable/channel.rb +4 -0
  6. data/lib/anycable/rails/actioncable/connection.rb +39 -35
  7. data/lib/anycable/rails/actioncable/connection/persistent_session.rb +7 -3
  8. data/lib/anycable/rails/actioncable/connection/serializable_identification.rb +42 -0
  9. data/lib/anycable/rails/actioncable/remote_connections.rb +11 -0
  10. data/lib/anycable/rails/actioncable/testing.rb +35 -0
  11. data/lib/anycable/rails/channel_state.rb +46 -0
  12. data/lib/anycable/rails/compatibility.rb +4 -7
  13. data/lib/anycable/rails/compatibility/rubocop.rb +0 -1
  14. data/lib/anycable/rails/compatibility/rubocop/config/default.yml +3 -0
  15. data/lib/anycable/rails/compatibility/rubocop/cops/anycable/instance_vars.rb +1 -1
  16. data/lib/anycable/rails/compatibility/rubocop/cops/anycable/stream_from.rb +4 -4
  17. data/lib/anycable/rails/railtie.rb +26 -18
  18. data/lib/anycable/rails/refinements/subscriptions.rb +5 -0
  19. data/lib/anycable/rails/session_proxy.rb +19 -2
  20. data/lib/anycable/rails/version.rb +1 -1
  21. data/lib/generators/anycable/download/USAGE +14 -0
  22. data/lib/generators/anycable/download/download_generator.rb +83 -0
  23. data/lib/generators/anycable/setup/USAGE +2 -0
  24. data/lib/{rails/generators → generators}/anycable/setup/setup_generator.rb +100 -88
  25. data/lib/generators/anycable/setup/templates/Procfile.dev.tt +6 -0
  26. data/lib/{rails/generators → generators}/anycable/setup/templates/config/anycable.yml.tt +22 -4
  27. data/lib/generators/anycable/setup/templates/config/cable.yml.tt +11 -0
  28. data/lib/{rails/generators/anycable/setup/templates/config/initializers/anycable.rb → generators/anycable/setup/templates/config/initializers/anycable.rb.tt} +1 -1
  29. data/lib/generators/anycable/with_os_helpers.rb +55 -0
  30. metadata +29 -52
  31. data/lib/anycable/rails/compatibility/rubocop/cops/anycable/remote_disconnect.rb +0 -31
  32. data/lib/rails/generators/anycable/setup/templates/Procfile +0 -2
  33. data/lib/rails/generators/anycable/setup/templates/Procfile.dev +0 -3
  34. data/lib/rails/generators/anycable/setup/templates/bin/heroku-web +0 -7
  35. data/lib/rails/generators/anycable/setup/templates/config/cable.yml.tt +0 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 93c88ec3ccf3eb9d145474e43aa8a851e32768de9b7c8ce1e6eb44cc0b24b0e9
4
- data.tar.gz: b12bc69aa43afc035038ee85c80bce57b9beabe36d9d0b93f261125f3af32876
3
+ metadata.gz: 49d905b11d3ffb0c71c238ece809817adbbf336f489e1a317a692e9c50db0a5f
4
+ data.tar.gz: e632e101cb3e710548703da397843ef4c6f7df00f4afb2ba09a2a54a680ebd5c
5
5
  SHA512:
6
- metadata.gz: 387d765e0d5f15c38d211e206eccc04982c4d20c4855539de49caefa58caffd0dd7a949f73817d576fc19b97a1e6359d0dd194520a3e9538b18aee987a5aa99e
7
- data.tar.gz: c75876c69f2655296cefd54b3ac9cba5fdefcdabbea206c526d9ddb502fcb61095e2855582d5ca17884fdadf70e6e4406a43b5e21470b7ade8b6027064903c1e
6
+ metadata.gz: 1b6763e1152e6a2ce712053f6d6bc798c40af7f6fa01fc38f52e8105c924ac451c916ac7775e30dc83445f30b6956da4ddac1d83cda5360032b3c585f68bd0a5
7
+ data.tar.gz: d656c094dd40d392f2f1aaf093577e887d264dc75778b5a84da1563d24ce33c272ab34fdd526ec8d5ba22b5c5d570f0f86ba26b61821edbb21e2356446dd208b
@@ -1,152 +1,58 @@
1
1
  # Change log
2
2
 
3
- ## 🚧 1.0.0 (_coming soon_)
3
+ ## master
4
4
 
5
- - **Ruby 2.5+ is required**. ([@palkan][])
6
-
7
- - Support `disconnect` messages. ([@palkan][])
8
-
9
- Added in Rails 6 (see [PR#34194](https://github.com/rails/rails/pull/34194)).
10
-
11
- - Add ability to persist _dirty_ `request.session` between RPC calls. ([@palkan][])
12
-
13
- This feature emulates the Action Cable behaviour where it's possible to use `request.session` as a shared Hash-like store.
14
- This could be used by some applications (e.g., [StimulusReflex](https://github.com/hopsoft/stimulus_reflex)-based).
15
-
16
- You must turn this feature on by setting `persistent_session_enabled: true` in the AnyCable configuration.
17
-
18
- - Add ability to use Rack middlewares when build a request for a connection. ([@bibendi][])
19
-
20
- - Add set up generator to configure a Rails application by running `bin/rails g anycable:setup`. ([@bibendi][])
21
-
22
- - Require a minimum version of Ruby when installing the gem. ([@bibendi][])
23
-
24
- - Add ability to develop the gem with Docker. ([@bibendi][])
25
-
26
- ## 0.6.4 (2019-06-26) 👶
27
-
28
- - Fix Compatibility bug when using with AnyCable. ([@palkan][])
29
-
30
- Compatibility patching (with `prepend` + `super`) conflicted with
31
- the `ActionCable::Channel::Base` patching in the core functionality (which uses `alias`).
32
-
33
- See [#95](https://github.com/anycable/anycable-rails/issues/95).
34
-
35
- ## 0.6.3 (2019-03-26)
36
-
37
- - Fix connection factory reloading for development sake. ([@sponomarev][])
38
-
39
- - Add `:anycable` subscription adapter alias. ([@sponomarev][])
40
-
41
- - Don't set AnyCable connection factory for incompatible adapter ([@sponomarev][])
42
-
43
- `anycable` server won't start with unpatched vanilla `ApplicationCable::Connection`.
44
-
45
- Motivation in [#74](https://github.com/anycable/anycable-rails/issues/74).
46
-
47
- - Fix instance detection inside complex cases in compatibility cops ([@sponomarev][])
48
-
49
- ## 0.6.2 (2019-01-10)
50
-
51
- - Fixed `anycable` 0.6.1 compatibility. ([@palkan][])
52
-
53
- - Broadcast logs to STDOUT in development only when server is running. ([@palkan][])
5
+ ## 1.0.0 (2020-07-01)
54
6
 
55
- Fixes #59.
7
+ - Support `rescue_from` in connections (Rails 6.1). ([@palkan][])
56
8
 
57
- ## 0.6.1 (2018-11-15)
9
+ - Make AnyCable patches compatible with Action Cable testing. ([@palkan][])
58
10
 
59
- - Fix regression introduced in [e64a366e](https://github.com/anycable/anycable-rails/commit/e64a366ea21293925e0c5c0b8e6595d65d5d0981#diff-fd0e56a6e825002eac978507c3581af7R14) ([@palkan][])
11
+ - Do not add localhost `redis_url` to `anycable.yml` when Docker development method is chosen in `anycable:setup`. ([@palkan][])
60
12
 
61
- `Connection` patch could be loaded after `identify_by` is called, thus breaking
62
- identifiers.
13
+ - Fix connection identifiers deserialization regression. ([@palkan][])
63
14
 
64
- ## 0.6.0 (2018-11-15)
15
+ Using non-strings or non-GlobalId-encoded objects was broken.
65
16
 
66
- **NOTE**: this version has been yanked from RubyGems due to the regression bug. Use 0.6.1.
17
+ - Improve `anycable:setup` generator. ([@palkan][])
67
18
 
68
- - [PR #56](https://github.com/anycable/anycable-rails/pull/56) Request verification based on ActionCable config. ([@DmitryTsepelev][])
19
+ Update Docker snippet, do not enable persistent sessions automatically,
20
+ fix setting `config.action_cable.url` in environment configuration.
69
21
 
70
- - Add WS server session ID to log tags if present. ([@palkan][])
22
+ - Add `state_attr_accessor` for channels. ([@palkan][])
71
23
 
72
- - Support tagged logging. ([@palkan][])
24
+ Just like `attr_accessor` but "persists" the state between RPC calls.
73
25
 
74
- - Action Cable monkey-patches are only loaded in the context of AnyCable CLI. ([@palkan][])
26
+ - Add `Channel#stop_stream_from` support. ([@palkan][])
75
27
 
76
- No need to think about `requie` and `group` for `anycable-rails`, just add it to Gemfile.
28
+ - Add `RemoteConnections` support. ([@palkan][])
77
29
 
78
- - Add `:any_cable` subscription adapter for Action Cable. ([@palkan][])
30
+ - Add `AnyCable::Rails.enabled?` method which returns true if Action Cable uses AnyCable adapter. ([@palkan][])
79
31
 
80
- Use `:any_cable` adapter for Action Cable to broadcast data to AnyCable.
32
+ - Add `anycable:download` generator to download `anycable-go` binary. ([@palkan][])
81
33
 
82
- No more `pubsub` monkey-patches 🎉.
83
-
84
- - Added Rails executor/reloader support. ([@palkan][])
85
-
86
- - **[Breaking]** No more generators. ([@palkan][])
87
-
88
- No need to generate AnyCable runner script since `anycable` gem ships with
89
- the CLI.
90
-
91
- - Add dynamic (`AnyCable::CompatibilityError`) compatibility checks. ([@DmitryTsepelev][])
92
-
93
- - Added static (RuboCop) compatibility checks. ([@DmitryTsepelev][])
94
-
95
- See https://github.com/anycable/anycable-rails/issues/52
96
-
97
- ## 0.5.4 (2018-06-13)
98
-
99
- - Fix duplicate logs in development. ([@palkan][])
100
-
101
- Fixes https://github.com/anycable/anycable_demo/issues/5.
102
-
103
- ## 0.5.3
104
-
105
- - Fix return value of `Connection#handle_close`. ([@palkan][])
106
-
107
- Should always be `true`, we do not expect a failure here.
108
-
109
- ## 0.5.2
110
-
111
- - Add config/anycable.yml to Rails generator. ([@alekseyl][])
112
-
113
- ## 0.5.1
114
-
115
- - Improve Rails integration. ([@palkan][])
116
-
117
- Log to STDOUT in development.
118
- Make order of initializers more deterministic.
119
- Show warning if AnyCable is loaded after application initialization.
120
-
121
- ## 0.5.0
122
-
123
- - [#17](https://github.com/anycable/anycable-rails/issues/17) Refactor logging. ([@palkan][])
124
-
125
- Use Rails logger everywhere.
126
-
127
- Add access logs ([anycable/anycable#20](https://github.com/anycable/anycable/issues/20)).
128
-
129
- ## 0.4.7
34
+ - **Ruby 2.5+ is required**. ([@palkan][])
130
35
 
131
- - Minor fixes. ([@palkan][])
36
+ - Support `disconnect` messages. ([@palkan][])
132
37
 
133
- ## 0.4.6
38
+ Added in Rails 6 (see [PR#34194](https://github.com/rails/rails/pull/34194)).
134
39
 
135
- - Disable mounting default Action Cable server when AnyCable is loaded. ([@palkan][])
40
+ - Add ability to persist _dirty_ `request.session` between RPC calls. ([@palkan][])
136
41
 
137
- ## 0.4.5
42
+ This feature emulates the Action Cable behaviour where it's possible to use `request.session` as a shared Hash-like store.
43
+ This could be used by some applications (e.g., [StimulusReflex](https://github.com/hopsoft/stimulus_reflex)-based).
138
44
 
139
- - Handle tagged logger. ([@palkan][])
45
+ You must turn this feature on by setting `persistent_session_enabled: true` in the AnyCable configuration.
140
46
 
141
- Ignore tagged logger features ('cause we do not have _persistent_ logger).
47
+ - Add ability to use Rack middlewares when build a request for a connection. ([@bibendi][])
142
48
 
143
- ## 0.4.4
49
+ - Add set up generator to configure a Rails application by running `bin/rails g anycable:setup`. ([@bibendi][])
144
50
 
145
- - Fix bug with ActiveRecord connections (https://github.com/anycable/anycable/issues/9). ([@palkan][])
51
+ - Require a minimum version of Ruby when installing the gem. ([@bibendi][])
146
52
 
147
- ## 0.4.0
53
+ - Add ability to develop the gem with Docker. ([@bibendi][])
148
54
 
149
- - Initial version. ([@palkan][])
55
+ See [Changelog](https://github.com/anycable/anycable-rails/blob/0-6-stable/CHANGELOG.md) for versions <1.0.0.
150
56
 
151
57
  [@palkan]: https://github.com/palkan
152
58
  [@alekseyl]: https://github.com/alekseyl
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
- [![GitPitch](https://gitpitch.com/assets/badge.svg)](https://gitpitch.com/anycable/anycable/master?grs=github) [![Gem Version](https://badge.fury.io/rb/anycable-rails.svg)](https://rubygems.org/gems/anycable-rails) [![Build Status](https://travis-ci.org/anycable/anycable-rails.svg?branch=master)](https://travis-ci.org/anycable/anycable-rails)
1
+ [![GitPitch](https://gitpitch.com/assets/badge.svg)](https://gitpitch.com/anycable/anycable/master?grs=github)
2
+ [![Gem Version](https://badge.fury.io/rb/anycable-rails.svg)](https://rubygems.org/gems/anycable-rails)
3
+ [![Build](https://github.com/anycable/anycable-rails/workflows/Build/badge.svg)](https://github.com/anycable/anycable-rails/actions)
2
4
  [![Gitter](https://img.shields.io/badge/gitter-join%20chat%20%E2%86%92-brightgreen.svg)](https://gitter.im/anycable/Lobby)
3
- [![Documentation](https://img.shields.io/badge/docs-link-brightgreen.svg)](https://docs.anycable.io/#/ruby/rails)
5
+ [![Documentation](https://img.shields.io/badge/docs-link-brightgreen.svg)](https://docs.anycable.io/v1/#/ruby/rails)
4
6
 
5
7
  # AnyCable Rails
6
8
 
@@ -10,10 +12,11 @@ With AnyCable you can use channels, client-side JS, broadcasting - (almost) all
10
12
 
11
13
  You can even use Action Cable in development and not be afraid of [compatibility issues](#compatibility).
12
14
 
13
- 💾 [Example Application](https://github.com/anycable/anycable_demo)
15
+ **Important** This is a readme for the upcoming v1.0 release. For v0.6.x see the readme from the [0-6-stable](https://github.com/anycable/anycable-rails/tree/0-6-stable) branch.
14
16
 
15
- 📑 [Documentation](https://docs.anycable.io).
17
+ <!-- 💾 [Example Application](https://github.com/anycable/anycable_demo) -->
16
18
 
19
+ 📑 [Documentation](https://docs.anycable.io/v1/#/ruby/rails).
17
20
 
18
21
  <a href="https://evilmartians.com/">
19
22
  <img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg" alt="Sponsored by Evil Martians" width="236" height="54"></a>
@@ -21,12 +24,8 @@ You can even use Action Cable in development and not be afraid of [compatibility
21
24
  ## Requirements
22
25
 
23
26
  - Ruby >= 2.5
24
- - Rails >= 5.0;
25
- - Redis (see [other options]() for broadcasting)
26
-
27
- ## How It Works?
28
-
29
- <img src="https://trello-attachments.s3.amazonaws.com/5781e0ed48e4679e302833d3/820x987/5b6a305417b04e20e75f49c5816e027c/Anycable_vs_ActionCable_copy.jpg" width="400" />
27
+ - Rails >= 5.2
28
+ - Redis (see [other options](https://github.com/anycable/anycable/issues/2) for broadcasting)
30
29
 
31
30
  ## Usage
32
31
 
@@ -39,14 +38,12 @@ gem "anycable-rails"
39
38
  gem "redis", ">= 4.0"
40
39
  ```
41
40
 
42
- (and don't forget to run `bundle install`).
43
-
44
41
  ### Interactive set up
45
42
 
46
43
  After the gem was installed, you can run an interactive wizard to configure your Rails application for using with AnyCable by running a generator:
47
44
 
48
45
  ```sh
49
- bin/rails g anycable:setup
46
+ bundle exec rails g anycable:setup
50
47
  ```
51
48
 
52
49
  ### Manual set up
@@ -86,38 +83,21 @@ $ bundle exec anycable
86
83
  $ RAILS_ENV=production bundle exec anycable
87
84
  ```
88
85
 
89
- And, finally, run AnyCable WebSocket server, e.g. [anycable-go](https://docs.anycable.io/#/anycable-go/getting_started):
86
+ And, finally, run AnyCable WebSocket server, e.g. [anycable-go](https://docs.anycable.io/v1/#/anycable-go/getting_started):
90
87
 
91
88
  ```sh
92
89
  anycable-go --host=localhost --port=3334
93
90
  ```
94
91
 
95
- See [documentation](https://docs.anycable.io/#/ruby/rails) for more information on AnyCable + Rails usage.
92
+ See [documentation](https://docs.anycable.io/v1/#/ruby/rails) for more information on AnyCable + Rails usage.
96
93
 
97
94
  ## Action Cable Compatibility
98
95
 
99
- See [documentation](https://docs.anycable.io/#/ruby/compatibility).
100
-
101
- ## Links
102
-
103
- - [AnyCable: Action Cable on steroids!](https://evilmartians.com/chronicles/anycable-actioncable-on-steroids)
104
-
105
- - [From Action to Any](https://medium.com/@leshchuk/from-action-to-any-1e8d863dd4cf) by [@alekseyl](https://github.com/alekseyl)
106
-
107
- ## Talks
108
-
109
- - One cable to rule them all, RubyKaigi 2018, [slides](https://speakerdeck.com/palkan/rubykaigi-2018-anycable-one-cable-to-rule-them-all) and [video](https://www.youtube.com/watch?v=jXCPuNICT8s) (EN)
110
-
111
- - Wroc_Love.rb 2018 [slides](https://speakerdeck.com/palkan/wroc-love-dot-rb-2018-cables-cables-cables) and [video](https://www.youtube.com/watch?v=AUxFFOehiy0) (EN)
112
-
113
- ## Compatible WebSocket servers
114
-
115
- - [AnyCable Go](https://github.com/anycable/anycable-go)
116
- - [ErlyCable](https://github.com/anycable/erlycable)
96
+ See [documentation](https://docs.anycable.io/v1/#/ruby/compatibility).
117
97
 
118
98
  ## Contributing
119
99
 
120
- Bug reports and pull requests are welcome on GitHub at https://github.com/anycable/anycable-rails.
100
+ Bug reports and pull requests are welcome on GitHub at [https://github.com/anycable/anycable-rails](https://github.com/anycable/anycable-rails).
121
101
 
122
102
  ## Development
123
103
 
@@ -5,6 +5,8 @@ require "anycable/rails/version"
5
5
  require "anycable/rails/config"
6
6
  require "anycable/rails/rack"
7
7
 
8
+ require "globalid"
9
+
8
10
  module AnyCable
9
11
  # Rails handler for AnyCable
10
12
  module Rails
@@ -12,8 +14,40 @@ module AnyCable
12
14
 
13
15
  ADAPTER_ALIASES = %w[any_cable anycable].freeze
14
16
 
15
- def self.compatible_adapter?(adapter)
16
- ADAPTER_ALIASES.include?(adapter)
17
+ class << self
18
+ def enabled?
19
+ adapter = ::ActionCable.server.config.cable&.fetch("adapter", nil)
20
+ compatible_adapter?(adapter)
21
+ end
22
+
23
+ def compatible_adapter?(adapter)
24
+ ADAPTER_ALIASES.include?(adapter)
25
+ end
26
+
27
+ # Serialize connection/channel state variable to string
28
+ # using GlobalID where possible or JSON (if json: true)
29
+ def serialize(obj, json: false)
30
+ obj.try(:to_gid_param) || (json ? obj.to_json : obj)
31
+ end
32
+
33
+ # Deserialize previously serialized value from string to
34
+ # Ruby object.
35
+ # If the resulting object is a Hash, make it indifferent
36
+ def deserialize(str, json: false)
37
+ str.yield_self do |val|
38
+ next val unless val.is_a?(String)
39
+
40
+ gval = GlobalID::Locator.locate(val)
41
+ return gval if gval
42
+
43
+ next val unless json
44
+
45
+ JSON.parse(val)
46
+ end.yield_self do |val|
47
+ next val.with_indifferent_access if val.is_a?(Hash)
48
+ val
49
+ end
50
+ end
17
51
  end
18
52
  end
19
53
  end
@@ -28,6 +28,10 @@ module ActionCable
28
28
  connection.socket.subscribe identifier, broadcasting
29
29
  end
30
30
 
31
+ def stop_stream_from(broadcasting)
32
+ connection.socket.unsubscribe identifier, broadcasting
33
+ end
34
+
31
35
  def stop_all_streams
32
36
  connection.socket.unsubscribe_from_all identifier
33
37
  end
@@ -1,8 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "action_cable/connection"
4
+ require "anycable/rails/actioncable/connection/serializable_identification"
4
5
  require "anycable/rails/refinements/subscriptions"
5
6
  require "anycable/rails/actioncable/channel"
7
+ require "anycable/rails/actioncable/remote_connections"
6
8
  require "anycable/rails/session_proxy"
7
9
 
8
10
  module ActionCable
@@ -15,26 +17,28 @@ module ActionCable
15
17
 
16
18
  using AnyCable::Refinements::Subscriptions
17
19
 
20
+ include SerializableIdentification
21
+
18
22
  attr_reader :socket
19
23
 
24
+ alias anycable_socket socket
25
+
20
26
  delegate :env, :session, to: :request
21
27
 
22
28
  class << self
23
29
  def call(socket, **options)
24
- new(socket, options)
30
+ new(socket, nil, options)
25
31
  end
32
+ end
26
33
 
27
- def identified_by(*identifiers)
28
- super
29
- Array(identifiers).each do |identifier|
30
- define_method(identifier) do
31
- instance_variable_get(:"@#{identifier}") || fetch_identifier(identifier)
32
- end
33
- end
34
+ def initialize(socket, env, identifiers: "{}", subscriptions: [])
35
+ if env
36
+ # If env is set, then somehow we're in the context of Action Cable
37
+ # Return and print a warning in #process
38
+ @request = ActionDispatch::Request.new(env)
39
+ return
34
40
  end
35
- end
36
41
 
37
- def initialize(socket, identifiers: "{}", subscriptions: [])
38
42
  @ids = ActiveSupport::JSON.decode(identifiers)
39
43
 
40
44
  @ltags = socket.cstate.read(LOG_TAGS_IDENTIFIER).yield_self do |raw_tags|
@@ -51,6 +55,18 @@ module ActionCable
51
55
  subscriptions.each { |id| @subscriptions.fetch(id) }
52
56
  end
53
57
 
58
+ def process
59
+ # Use Rails logger here to print to stdout in development
60
+ logger.error invalid_request_message
61
+ logger.info finished_request_message
62
+ [404, {"Content-Type" => "text/plain"}, ["Page not found"]]
63
+ end
64
+
65
+ def invalid_request_message
66
+ "You're trying to connect to Action Cable server while using AnyCable. " \
67
+ "See https://docs.anycable.io/v1/#/troubleshooting?id=server-raises-an-argumenterror-exception-when-client-tries-to-connect"
68
+ end
69
+
54
70
  def handle_open
55
71
  logger.info started_request_message if access_logs?
56
72
 
@@ -107,31 +123,6 @@ module ActionCable
107
123
  socket.transmit encode(cable_message)
108
124
  end
109
125
 
110
- # Generate identifiers info.
111
- # Converts GlobalID compatible vars to corresponding global IDs params.
112
- def identifiers_hash
113
- identifiers.each_with_object({}) do |id, acc|
114
- obj = instance_variable_get("@#{id}")
115
- next unless obj
116
-
117
- acc[id] = obj.try(:to_gid_param) || obj
118
- end.compact
119
- end
120
-
121
- def identifiers_json
122
- identifiers_hash.to_json
123
- end
124
-
125
- # Fetch identifier and deserialize if neccessary
126
- def fetch_identifier(name)
127
- @cached_ids[name] ||= @cached_ids.fetch(name) do
128
- val = ids[name.to_s]
129
- next val unless val.is_a?(String)
130
-
131
- GlobalID::Locator.locate(val) || val
132
- end
133
- end
134
-
135
126
  def logger
136
127
  @logger ||= TaggedLoggerProxy.new(AnyCable.logger, tags: ltags || [])
137
128
  end
@@ -207,3 +198,16 @@ module ActionCable
207
198
  # rubocop:enable Metrics/ClassLength
208
199
  end
209
200
  end
201
+
202
+ # Support rescue_from
203
+ # https://github.com/rails/rails/commit/d2571e560c62116f60429c933d0c41a0e249b58b
204
+ if ActionCable::Connection::Base.respond_to?(:rescue_from)
205
+ ActionCable::Connection::Base.prepend(Module.new do
206
+ def handle_channel_command(*)
207
+ super
208
+ rescue Exception => e # rubocop:disable Lint/RescueException
209
+ rescue_with_handler(e) || raise
210
+ false
211
+ end
212
+ end)
213
+ end