anycable-rails 1.0.3 → 1.1.0.rc1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6f7915a5f8edaf8e0053df398cef7ad663ce71ec69456e7f6c3e8d539d8724a8
4
- data.tar.gz: 1349a0b4d6bff65540b940e8963578af24733ffdf3b51ed73cc3b11e85483d4a
3
+ metadata.gz: 1cf996e781322b7becc433bf984818a12961d26b0eb2b21429f3c40bdc076b51
4
+ data.tar.gz: 880681dd3742f032553906f730e5eec9618dedec32d05dff7b474e7a567f42a4
5
5
  SHA512:
6
- metadata.gz: c4501650b155d991cdca302a1ba225ca6c09e00b637d6589f741512d3ef20b62589dd98f550be7599b75a05e3be0a6f8e7caa105c37d6b6923181f20730e5a21
7
- data.tar.gz: f973cbb37b67a1abe9f4a4acfd73cd88f8dfad2673a9c919eda6720bc647242748311429ef46e00b1e5bc02f8bf892d52a72218cd1ac2f28c77323039f80a91d
6
+ metadata.gz: e02e9ee1686ef5474400961c271ce55aba57c29c9d9843e0c8f90f7343366ddc753aedfc29e4136d11bc9acbb3b27787052f10f9d3521fcbb9df2598a890cff7
7
+ data.tar.gz: 7bed57ab2cc71df212205b1c79ed926384804e1ce917f43bf028c7a855087b8fdbdbf9da10ec236d4c15ed8edae5a2ede8704a93540a4773520c4fe7f135129a
data/CHANGELOG.md CHANGED
@@ -2,6 +2,37 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 1.1.0.rc1
6
+
7
+ - Add option to embed AnyCable RPC into a Rails server process. ([@palkan][])
8
+
9
+ Set `embedded: true` in the configuration to launch RPC along with `rails s` (only for Rails 6.1+).
10
+
11
+ - **Ruby >= 2.6** is required.
12
+ - **Rails >= 6.0** is required.
13
+
14
+ ## 1.0.7 (2021-03-05)
15
+
16
+ - Ruby 3 compatibility. ([@palkan][])
17
+
18
+ ## 1.0.6 (2021-02-25)
19
+
20
+ - Keep an explicit list of instance vars to ignore in compatibility checks. ([@palkan][])
21
+
22
+ You can ignore custom vars by adding them to the list: `AnyCable::Compatibility::IGNORE_INSTANCE_VARS << :@my_var`.
23
+
24
+ ## 1.0.5 (2021-02-24)
25
+
26
+ - Fixed bug with compatibility false negatives in development. ([@palkan][])
27
+
28
+ See [#151](https://github.com/anycable/anycable-rails/issues/151).
29
+
30
+ ## 1.0.4 (2020-10-02)
31
+
32
+ - Relax Rails dependencies. ([@palkan][])
33
+
34
+ Only add `actioncable` and `globalid` as runtime dependencies, not the whole `rails`.
35
+
5
36
  ## 1.0.3 (2020-09-16)
6
37
 
7
38
  - Fixed bug with building a request object when session store is absent. ([@palkan][])
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2017-2020 palkan
1
+ Copyright 2017-2021 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
@@ -1,4 +1,3 @@
1
- [![GitPitch](https://gitpitch.com/assets/badge.svg)](https://gitpitch.com/anycable/anycable/master?grs=github)
2
1
  [![Gem Version](https://badge.fury.io/rb/anycable-rails.svg)](https://rubygems.org/gems/anycable-rails)
3
2
  [![Build](https://github.com/anycable/anycable-rails/workflows/Build/badge.svg)](https://github.com/anycable/anycable-rails/actions)
4
3
  [![Gitter](https://img.shields.io/badge/gitter-join%20chat%20%E2%86%92-brightgreen.svg)](https://gitter.im/anycable/Lobby)
@@ -12,8 +11,6 @@ With AnyCable you can use channels, client-side JS, broadcasting - (almost) all
12
11
 
13
12
  You can even use Action Cable in development and not be afraid of [compatibility issues](#compatibility).
14
13
 
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.
16
-
17
14
  💾 [Example Application](https://github.com/anycable/anycable_rails_demo)
18
15
 
19
16
  📑 [Documentation](https://docs.anycable.io/#/rails/getting_started).
@@ -23,8 +20,8 @@ You can even use Action Cable in development and not be afraid of [compatibility
23
20
 
24
21
  ## Requirements
25
22
 
26
- - Ruby >= 2.5
27
- - Rails >= 5.2
23
+ - Ruby >= 2.6
24
+ - Rails >= 6.0
28
25
  - Redis (see [other options](https://github.com/anycable/anycable/issues/2) for broadcasting)
29
26
 
30
27
  ## Usage
@@ -65,7 +62,7 @@ and specify AnyCable WebSocket server URL:
65
62
  # For development it's likely the localhost
66
63
 
67
64
  # config/environments/development.rb
68
- config.action_cable.url = "ws://localhost:3334/cable"
65
+ config.action_cable.url = "ws://localhost:8080/cable"
69
66
 
70
67
  # For production it's likely to have a sub-domain and secure connection
71
68
 
@@ -86,7 +83,7 @@ $ RAILS_ENV=production bundle exec anycable
86
83
  And, finally, run AnyCable WebSocket server, e.g. [anycable-go](https://docs.anycable.io/#/v1/anycable-go/getting_started):
87
84
 
88
85
  ```sh
89
- anycable-go --host=localhost --port=3334
86
+ anycable-go --host=localhost --port=8080
90
87
  ```
91
88
 
92
89
  See [documentation](https://docs.anycable.io/#/rails/getting_started) for more information on AnyCable + Rails usage.
@@ -99,10 +96,6 @@ See [documentation](https://docs.anycable.io/#/rails/compatibility).
99
96
 
100
97
  Bug reports and pull requests are welcome on GitHub at [https://github.com/anycable/anycable-rails](https://github.com/anycable/anycable-rails).
101
98
 
102
- ## Development
103
-
104
- If you are familiar with Docker, you can use [DIP](https://github.com/bibendi/dip) to start developing the gem quickly.
105
-
106
99
  ## License
107
100
 
108
101
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -5,7 +5,7 @@ require "action_cable/channel"
5
5
  module ActionCable
6
6
  module Channel
7
7
  class Base # :nodoc:
8
- alias handle_subscribe subscribe_to_channel
8
+ alias_method :handle_subscribe, :subscribe_to_channel
9
9
 
10
10
  public :handle_subscribe, :subscription_rejected?
11
11
 
@@ -21,13 +21,13 @@ module ActionCable
21
21
 
22
22
  attr_reader :socket
23
23
 
24
- alias anycable_socket socket
24
+ alias_method :anycable_socket, :socket
25
25
 
26
26
  delegate :env, :session, to: :request
27
27
 
28
28
  class << self
29
29
  def call(socket, **options)
30
- new(socket, nil, options)
30
+ new(socket, nil, **options)
31
31
  end
32
32
  end
33
33
 
@@ -12,15 +12,13 @@ end
12
12
 
13
13
  ActionCable::Channel::ChannelStub.prepend(Module.new do
14
14
  def subscribe_to_channel
15
- # allocate @streams
16
- streams
17
15
  handle_subscribe
18
16
  end
19
17
  end)
20
18
 
21
19
  ActionCable::Channel::ConnectionStub.prepend(Module.new do
22
20
  def socket
23
- @socket ||= AnyCable::Socket.new(env: {})
21
+ @socket ||= AnyCable::Socket.new(env: AnyCable::Env.new(url: "http://test.host", headers: {}))
24
22
  end
25
23
 
26
24
  alias_method :anycable_socket, :socket
@@ -4,6 +4,11 @@ module AnyCable
4
4
  class CompatibilityError < StandardError; end
5
5
 
6
6
  module Compatibility # :nodoc:
7
+ IGNORE_INSTANCE_VARS = %i[
8
+ @active_periodic_timers
9
+ @_streams
10
+ ]
11
+
7
12
  ActionCable::Channel::Base.prepend(Module.new do
8
13
  def stream_from(broadcasting, callback = nil, coder: nil)
9
14
  if coder.present? && coder != ActiveSupport::JSON
@@ -31,7 +36,7 @@ module AnyCable
31
36
  def __anycable_check_ivars__
32
37
  was_ivars = instance_variables
33
38
  res = yield
34
- diff = instance_variables - was_ivars
39
+ diff = instance_variables - was_ivars - IGNORE_INSTANCE_VARS
35
40
 
36
41
  if self.class.respond_to?(:channel_state_attributes)
37
42
  diff.delete(:@__istate__)
@@ -5,8 +5,10 @@ require "anycable/config"
5
5
  # Extend AnyCable configuration with:
6
6
  # - `access_logs_disabled` (defaults to true) — whether to print Started/Finished logs
7
7
  # - `persistent_session_enabled` (defaults to false) — whether to store session changes in the connection state
8
+ # - `embedded` (defaults to false) — whether to run RPC server inside a Rails server process
8
9
  AnyCable::Config.attr_config(
9
10
  access_logs_disabled: true,
10
- persistent_session_enabled: false
11
+ persistent_session_enabled: false,
12
+ embedded: false
11
13
  )
12
14
  AnyCable::Config.ignore_options :access_logs_disabled, :persistent_session_enabled
@@ -9,8 +9,8 @@ module AnyCable
9
9
  #
10
10
  # See https://github.com/grpc/grpc-go/blob/master/Documentation/grpc-metadata.md
11
11
  class LogTagging < AnyCable::Middleware
12
- def call(_request, call, _method)
13
- sid = call.metadata["sid"]
12
+ def call(_method, _request, metadata)
13
+ sid = metadata["sid"]
14
14
  return yield unless sid
15
15
 
16
16
  AnyCable.logger.tagged("AnyCable sid=#{sid}") { yield }
@@ -18,8 +18,8 @@ module AnyCable
18
18
  AnyCable.logger = ActiveSupport::TaggedLogging.new(::ActionCable.server.config.logger)
19
19
  # Broadcast server logs to STDOUT in development
20
20
  if ::Rails.env.development? &&
21
- !ActiveSupport::Logger.logger_outputs_to?(::Rails.logger, STDOUT)
22
- console = ActiveSupport::Logger.new(STDOUT)
21
+ !ActiveSupport::Logger.logger_outputs_to?(::Rails.logger, $stdout)
22
+ console = ActiveSupport::Logger.new($stdout)
23
23
  console.formatter = ::Rails.logger.formatter
24
24
  console.level = ::Rails.logger.level
25
25
  AnyCable.logger.extend(ActiveSupport::Logger.broadcast(console))
@@ -59,6 +59,16 @@ module AnyCable
59
59
  end
60
60
  end
61
61
  end
62
+
63
+ # Since Rails 6.1
64
+ if respond_to?(:server)
65
+ server do
66
+ next unless AnyCable.config.embedded?
67
+
68
+ require "anycable/cli"
69
+ AnyCable::CLI.embed!
70
+ end
71
+ end
62
72
  end
63
73
  end
64
74
  end
@@ -21,8 +21,8 @@ module AnyCable
21
21
  CODE
22
22
  end
23
23
 
24
- alias include? has_key?
25
- alias key? has_key?
24
+ alias_method :include?, :has_key?
25
+ alias_method :key?, :has_key?
26
26
 
27
27
  %i[update merge! to_hash].each do |mid|
28
28
  class_eval <<~CODE, __FILE__, __LINE__ + 1
@@ -33,7 +33,7 @@ module AnyCable
33
33
  CODE
34
34
  end
35
35
 
36
- alias to_h to_hash
36
+ alias_method :to_h, :to_hash
37
37
 
38
38
  def keys
39
39
  rack_session.keys + socket_session.keys
@@ -2,6 +2,6 @@
2
2
 
3
3
  module AnyCable
4
4
  module Rails
5
- VERSION = "1.0.3"
5
+ VERSION = "1.1.0.rc1"
6
6
  end
7
7
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Add Warden middkeware to AnyCable stack to allow accessing
3
+ # Add Warden middleware to AnyCable stack to allow accessing
4
4
  # Devise current user via `env["warden"].user`.
5
5
  #
6
6
  # See <%= DOCS_ROOT %>/ruby/authentication
metadata CHANGED
@@ -1,43 +1,63 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anycable-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.1.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - palkan
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-16 00:00:00.000000000 Z
11
+ date: 2021-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: anycable
14
+ name: anycable-core
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.99
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '2.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">"
28
+ - !ruby/object:Gem::Version
29
+ version: 1.0.99
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '2.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: actioncable
15
35
  requirement: !ruby/object:Gem::Requirement
16
36
  requirements:
17
37
  - - ">="
18
38
  - !ruby/object:Gem::Version
19
- version: 1.0.0
39
+ version: '6'
20
40
  type: :runtime
21
41
  prerelease: false
22
42
  version_requirements: !ruby/object:Gem::Requirement
23
43
  requirements:
24
44
  - - ">="
25
45
  - !ruby/object:Gem::Version
26
- version: 1.0.0
46
+ version: '6'
27
47
  - !ruby/object:Gem::Dependency
28
- name: rails
48
+ name: globalid
29
49
  requirement: !ruby/object:Gem::Requirement
30
50
  requirements:
31
51
  - - ">="
32
52
  - !ruby/object:Gem::Version
33
- version: '5'
53
+ version: '0'
34
54
  type: :runtime
35
55
  prerelease: false
36
56
  version_requirements: !ruby/object:Gem::Requirement
37
57
  requirements:
38
58
  - - ">="
39
59
  - !ruby/object:Gem::Version
40
- version: '5'
60
+ version: '0'
41
61
  - !ruby/object:Gem::Dependency
42
62
  name: ammeter
43
63
  requirement: !ruby/object:Gem::Requirement
@@ -175,7 +195,8 @@ metadata:
175
195
  documentation_uri: https://docs.anycable.io/#/using_with_rails
176
196
  homepage_uri: https://anycable.io/
177
197
  source_code_uri: http://github.com/anycable/anycable-rails
178
- post_install_message:
198
+ funding_uri: https://github.com/sponsors/anycable
199
+ post_install_message:
179
200
  rdoc_options: []
180
201
  require_paths:
181
202
  - lib
@@ -183,15 +204,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
183
204
  requirements:
184
205
  - - ">="
185
206
  - !ruby/object:Gem::Version
186
- version: '2.5'
207
+ version: '2.6'
187
208
  required_rubygems_version: !ruby/object:Gem::Requirement
188
209
  requirements:
189
- - - ">="
210
+ - - ">"
190
211
  - !ruby/object:Gem::Version
191
- version: '0'
212
+ version: 1.3.1
192
213
  requirements: []
193
- rubygems_version: 3.0.6
194
- signing_key:
214
+ rubygems_version: 3.2.15
215
+ signing_key:
195
216
  specification_version: 4
196
217
  summary: Rails adapter for AnyCable
197
218
  test_files: []