anycable-rails 1.1.2 → 1.2.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
  SHA256:
3
- metadata.gz: 685b7383d4271b532926db2d03a03d5601ee3e17d0b3215a61a675fcbe88b04f
4
- data.tar.gz: b7472589e36cff91a90cd0a8735aebcc50d269c52a357e6ac39a22a1cd6f90b3
3
+ metadata.gz: d21ee870a0caaeed44d71d571303e0e9ab835457360ee1b205279f38379716e2
4
+ data.tar.gz: 0e1f4c986782474601d40228ae272ab795bd038ad837420b9a689f74c91edfcf
5
5
  SHA512:
6
- metadata.gz: df90a5b6cbde849fe23765fb8b42632d891d849b0cd8a6d867c0fcfcaa0e11d9504859b6842ffeb600eaec429cf6551a2e14546628f1786ca8f0cc0bccebb55c
7
- data.tar.gz: cbf7b61205381c41c6556a32916f30c2d2beb24af62fe742cd151b314b0209393278fa229a1c84fd6484e0584b53f32a0d238d2a3bbe23cdd422e09c41bb31d0
6
+ metadata.gz: 7cd248fd53e2f09632a9fec2e3439c788f70b96b40270480b0b519ac70738740df783afc7bf7d107bf718dfe08cf31e8880796beace87cc87b20b5aa69cf90e2
7
+ data.tar.gz: 6c8e6cedcdd61b58e0dcfd82dfa72a4f3f1e0591bb90e27ef7b8b5c10bbe51a37163f83b12daba720f64f9519cbeadb9fbcb24e9d9af5ec84e988faa1cc54ad0
data/CHANGELOG.md CHANGED
@@ -2,6 +2,30 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 1.2.1 (2021-01-31)
6
+
7
+ - Add a temporary fix to be compatible with `sentry-rails`. ([@palkan][])
8
+
9
+ See [#165](https://github.com/anycable/anycable-rails/issues/165).
10
+
11
+ - Run embedded RPC server only if `any_cable` adapter is used for Action Cable. ([@palkan][])
12
+
13
+ ## 1.2.0 (2021-12-21) 🎄
14
+
15
+ - Drop Rails 5 support.
16
+
17
+ - Drop Ruby 2.6 support.
18
+
19
+ ## 1.1.4 (2021-11-11)
20
+
21
+ - Added `Connection#state_attr_accessor`. ([@palkan][])
22
+
23
+ ## 1.1.3 (2021-10-11)
24
+
25
+ - Relax Action Cable dependency. ([@palkan][])
26
+
27
+ Action Cable 5.1 is allowed (though not recommended).
28
+
5
29
  ## 1.1.2 (2021-06-23)
6
30
 
7
31
  - Bring back dependency on `anycable` (instead of `anycable-core`). ([@palkan][])
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2017-2021 palkan
1
+ Copyright 2017-2022 palkan
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -15,13 +15,15 @@ You can even use Action Cable in development and not be afraid of [compatibility
15
15
 
16
16
  📑 [Documentation](https://docs.anycable.io/rails/getting_started).
17
17
 
18
+ > [AnyCable Pro](https://docs.anycable.io/pro) has been launched 🚀
19
+
18
20
  <a href="https://evilmartians.com/">
19
21
  <img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg" alt="Sponsored by Evil Martians" width="236" height="54"></a>
20
22
 
21
23
  ## Requirements
22
24
 
23
25
  - Ruby >= 2.6
24
- - Rails >= 6.0
26
+ - Rails >= 6.0 (Rails 5.1 could work but we're no longer enforce compatibility on CI)
25
27
  - Redis (see [other options](https://github.com/anycable/anycable/issues/2) for broadcasting)
26
28
 
27
29
  ## Usage
@@ -9,7 +9,6 @@ require "anycable/rails/session_proxy"
9
9
 
10
10
  module ActionCable
11
11
  module Connection
12
- # rubocop: disable Metrics/ClassLength
13
12
  class Base # :nodoc:
14
13
  # We store logger tags in the connection state to be able
15
14
  # to re-use them in the subsequent calls
@@ -98,7 +97,6 @@ module ActionCable
98
97
  true
99
98
  end
100
99
 
101
- # rubocop:disable Metrics/MethodLength
102
100
  def handle_channel_command(identifier, command, data)
103
101
  channel = subscriptions.fetch(identifier)
104
102
  case command
@@ -5,7 +5,7 @@
5
5
  # Trigger autoload (if constant is defined)
6
6
  begin
7
7
  ActionCable::Channel::TestCase # rubocop:disable Lint/Void
8
- ActionCable::Connection::TestCase # rubocop:disable Lint/Void
8
+ ActionCable::Connection::TestCase
9
9
  rescue NameError
10
10
  return
11
11
  end
@@ -44,10 +44,65 @@ module AnyCable
44
44
  @__istate__ ||= connection.socket.istate
45
45
  end
46
46
  end
47
+
48
+ module ConnectionState
49
+ module ClassMethods
50
+ def state_attr_accessor(*names)
51
+ names.each do |name|
52
+ connection_state_attributes << name
53
+ class_eval <<~RUBY, __FILE__, __LINE__ + 1
54
+ def #{name}
55
+ return @#{name} if instance_variable_defined?(:@#{name})
56
+ @#{name} = AnyCable::Rails.deserialize(__cstate__["#{name}"], json: true) if anycable_socket
57
+ end
58
+
59
+ def #{name}=(val)
60
+ __cstate__["#{name}"] = AnyCable::Rails.serialize(val, json: true) if anycable_socket
61
+ instance_variable_set(:@#{name}, val)
62
+ end
63
+ RUBY
64
+ end
65
+ end
66
+
67
+ def connection_state_attributes
68
+ return @connection_state_attributes if instance_variable_defined?(:@connection_state_attributes)
69
+
70
+ @connection_state_attributes =
71
+ if superclass.respond_to?(:connection_state_attributes)
72
+ superclass.connection_state_attributes.dup
73
+ else
74
+ []
75
+ end
76
+ end
77
+ end
78
+
79
+ def self.included(base)
80
+ base.extend ClassMethods
81
+ end
82
+
83
+ # Make it possible to provide istate explicitly for a connection instance
84
+ attr_writer :__cstate__
85
+
86
+ def __cstate__
87
+ @__cstate__ ||= socket.cstate
88
+ end
89
+ end
47
90
  end
48
91
  end
49
92
 
50
- ActiveSupport.on_load(:action_cable) do
93
+ if ActiveSupport::VERSION::MAJOR < 6
94
+ # `state_attr_accessor` must be available in Action Cable
95
+ ActiveSupport.on_load(:action_cable) do
96
+ ::ActionCable::Connection::Base.include(AnyCable::Rails::ConnectionState)
97
+ ::ActionCable::Channel::Base.include(AnyCable::Rails::ChannelState)
98
+ end
99
+ else
51
100
  # `state_attr_accessor` must be available in Action Cable
52
- ::ActionCable::Channel::Base.include(AnyCable::Rails::ChannelState)
101
+ ActiveSupport.on_load(:action_cable_connection) do
102
+ ::ActionCable::Connection::Base.include(AnyCable::Rails::ConnectionState)
103
+ end
104
+
105
+ ActiveSupport.on_load(:action_cable_channel) do
106
+ ::ActionCable::Channel::Base.include(AnyCable::Rails::ChannelState)
107
+ end
53
108
  end
@@ -60,10 +60,17 @@ module AnyCable
60
60
  end
61
61
  end
62
62
 
63
+ # Temp hack to fix Sentry vs AnyCable incompatibility
64
+ # See https://github.com/anycable/anycable-rails/issues/165
65
+ initializer "anycable.sentry_hack", after: :"sentry.extend_action_cable" do
66
+ next unless defined?(::Sentry::Rails::ActionCableExtensions::Connection)
67
+ Sentry::Rails::ActionCableExtensions::Connection.send :public, :handle_open, :handle_close
68
+ end
69
+
63
70
  # Since Rails 6.1
64
71
  if respond_to?(:server)
65
72
  server do
66
- next unless AnyCable.config.embedded?
73
+ next unless AnyCable.config.embedded? && AnyCable::Rails.enabled?
67
74
 
68
75
  require "anycable/cli"
69
76
  AnyCable::CLI.embed!
@@ -2,6 +2,6 @@
2
2
 
3
3
  module AnyCable
4
4
  module Rails
5
- VERSION = "1.1.2"
5
+ VERSION = "1.2.1"
6
6
  end
7
7
  end
@@ -24,6 +24,12 @@ module AnyCableRailsGenerators
24
24
  class_option :skip_procfile_dev,
25
25
  type: :boolean,
26
26
  desc: "Do not create Procfile.dev"
27
+ class_option :skip_jwt,
28
+ type: :boolean,
29
+ desc: "Do not install anycable-rails-jwt"
30
+ class_option :skip_install,
31
+ type: :boolean,
32
+ desc: "Do not run bundle install when adding new gems"
27
33
 
28
34
  include WithOSHelpers
29
35
 
@@ -59,7 +65,7 @@ module AnyCableRailsGenerators
59
65
  <<~SNIPPET
60
66
  # Specify AnyCable WebSocket server URL to use by JS client
61
67
  config.after_initialize do
62
- config.action_cable.url = ActionCable.server.config.url = ENV.fetch("CABLE_URL") if AnyCable::Rails.enabled?
68
+ config.action_cable.url = ActionCable.server.config.url = ENV.fetch("CABLE_URL", "/cable") if AnyCable::Rails.enabled?
63
69
  end
64
70
  SNIPPET
65
71
  end
@@ -129,6 +135,16 @@ module AnyCableRailsGenerators
129
135
  say_status :help, "⚠️ Please, take a look at the icompatibilities above and fix them. See #{DOCS_ROOT}/rails/compatibility" unless res
130
136
  end
131
137
 
138
+ def jwt
139
+ return if options[:skip_jwt]
140
+
141
+ return unless options[:skip_jwt] == false || yes?("Do you want to use JWT for authentication? [Yn]")
142
+
143
+ opts = " --skip-install" if options[:skip_install]
144
+
145
+ run "bundle add anycable-rails-jwt#{opts}"
146
+ end
147
+
132
148
  def finish
133
149
  say_status :info, "✅ AnyCable has been configured successfully!"
134
150
  end
@@ -172,7 +188,7 @@ module AnyCableRailsGenerators
172
188
  say <<~YML
173
189
  ─────────────────────────────────────────
174
190
  ws:
175
- image: anycable/anycable-go:1.0
191
+ image: anycable/anycable-go:1.2
176
192
  ports:
177
193
  - '8080:8080'
178
194
  environment:
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anycable-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - palkan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-23 00:00:00.000000000 Z
11
+ date: 2022-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: anycable
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.1'
19
+ version: 1.2.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.1'
26
+ version: 1.2.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: actioncable
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '6'
33
+ version: '6.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '6'
40
+ version: '6.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: globalid
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -198,14 +198,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
198
198
  requirements:
199
199
  - - ">="
200
200
  - !ruby/object:Gem::Version
201
- version: '2.6'
201
+ version: '2.7'
202
202
  required_rubygems_version: !ruby/object:Gem::Requirement
203
203
  requirements:
204
204
  - - ">="
205
205
  - !ruby/object:Gem::Version
206
206
  version: '0'
207
207
  requirements: []
208
- rubygems_version: 3.2.15
208
+ rubygems_version: 3.2.22
209
209
  signing_key:
210
210
  specification_version: 4
211
211
  summary: Rails adapter for AnyCable