anycable-rails 0.5.5 → 0.6.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE.md +29 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +31 -0
- data/.rubocop.yml +24 -34
- data/CHANGELOG.md +31 -1
- data/README.md +47 -92
- data/Rakefile +7 -2
- data/anycable-rails.gemspec +3 -3
- data/lib/action_cable/subscription_adapter/any_cable.rb +23 -0
- data/lib/anycable/rails.rb +4 -4
- data/lib/anycable/rails/actioncable/channel.rb +8 -4
- data/lib/anycable/rails/actioncable/connection.rb +57 -23
- data/lib/anycable/rails/compatibility.rb +57 -0
- data/lib/anycable/rails/compatibility/rubocop.rb +28 -0
- data/lib/anycable/rails/compatibility/rubocop/config/default.yml +12 -0
- data/lib/anycable/rails/compatibility/rubocop/cops/anycable/instance_vars.rb +50 -0
- data/lib/anycable/rails/compatibility/rubocop/cops/anycable/periodical_timers.rb +29 -0
- data/lib/anycable/rails/compatibility/rubocop/cops/anycable/remote_disconnect.rb +31 -0
- data/lib/anycable/rails/compatibility/rubocop/cops/anycable/stream_from.rb +100 -0
- data/lib/anycable/rails/config.rb +3 -2
- data/lib/anycable/rails/middlewares/executor.rb +21 -0
- data/lib/anycable/rails/middlewares/log_tagging.rb +21 -0
- data/lib/anycable/rails/railtie.rb +20 -27
- data/lib/anycable/rails/refinements/subscriptions.rb +1 -1
- data/lib/anycable/rails/version.rb +2 -2
- metadata +25 -19
- data/lib/anycable/rails/actioncable/server.rb +0 -14
- data/lib/anycable/rails/activerecord/release_connection.rb +0 -29
- data/lib/generators/anycable/USAGE +0 -7
- data/lib/generators/anycable/anycable_generator.rb +0 -16
- data/lib/generators/anycable/templates/anycable.yml +0 -41
- data/lib/generators/anycable/templates/script +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23c007d1a03872b62769d01916c37dc08e65b209f7f2c03dc82506142dd9deba
|
4
|
+
data.tar.gz: 852a706ac6f822674f4f8ded679dd369b1fed46adfebf4687ff917e04d6b5dce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7d61c3f61e07ff50a5ab51598647befa8295345864afa913829cc4311aa178dc2841e1bc9ddce5cb5a2f822add9d2a0cc667ecef438cfed3e0c056d9c726497
|
7
|
+
data.tar.gz: 4d9233be76b119ca9b09dcdb010e9a9bc6fdfa1c883530b97455a2ec2d23331458991c442b40640006ee8aa07ec12f5e0df3bf6c6b3a705761184661761e40d5
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<!--
|
2
|
+
First of all, thanks for your report/suggestion/whatever!
|
3
|
+
|
4
|
+
This template is for bug reports. If you are reporting a bug, please continue on. If you are here for another reason,
|
5
|
+
feel free to skip the rest of this template.
|
6
|
+
-->
|
7
|
+
|
8
|
+
### Tell us about your environment
|
9
|
+
|
10
|
+
**Ruby version:**
|
11
|
+
|
12
|
+
**Rails version:**
|
13
|
+
|
14
|
+
**`anycable` gem version:**
|
15
|
+
|
16
|
+
**`anycable-rails` gem version:**
|
17
|
+
|
18
|
+
**`grpc` gem version:**
|
19
|
+
|
20
|
+
### What did you do?
|
21
|
+
|
22
|
+
### What did you expect to happen?
|
23
|
+
|
24
|
+
### What actually happened?
|
25
|
+
|
26
|
+
<!--
|
27
|
+
Please, provide reproduction script (using this template (https://github.com/anycable/anycable/blob/master/etc/bug_report_template.rb)
|
28
|
+
when submitting bugs if possible.
|
29
|
+
-->
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<!--
|
2
|
+
First of all, thanks for contributing!
|
3
|
+
|
4
|
+
If it's a typo fix or minor documentation update feel free to skip the rest of this template!
|
5
|
+
-->
|
6
|
+
|
7
|
+
<!--
|
8
|
+
If it's a bug fix, then link it to the issue, for example:
|
9
|
+
|
10
|
+
Fixes #xxx
|
11
|
+
-->
|
12
|
+
|
13
|
+
|
14
|
+
<!--
|
15
|
+
Otherwise, describe the changes:
|
16
|
+
|
17
|
+
### What is the purpose of this pull request?
|
18
|
+
|
19
|
+
### What changes did you make? (overview)
|
20
|
+
|
21
|
+
### Is there anything you'd like reviewers to focus on?
|
22
|
+
|
23
|
+
-->
|
24
|
+
|
25
|
+
<!--
|
26
|
+
Please ensure your PR is ready:
|
27
|
+
|
28
|
+
- Include tests for this change
|
29
|
+
- Add Changelog entry
|
30
|
+
- Update documentation for this change (if appropriate)
|
31
|
+
-->
|
data/.rubocop.yml
CHANGED
@@ -5,58 +5,45 @@ AllCops:
|
|
5
5
|
- 'lib/**/*.rake'
|
6
6
|
- 'spec/**/*.rb'
|
7
7
|
Exclude:
|
8
|
-
- '*.gemspec'
|
9
8
|
- 'bin/**/*'
|
10
|
-
- 'spec/dummy/**/*'
|
11
9
|
- 'tmp/**/*'
|
12
|
-
- '
|
10
|
+
- 'lib/anycable/rpc/**/*'
|
13
11
|
- 'vendor/**/*'
|
14
12
|
- 'gemfiles/**/*'
|
15
|
-
- 'lib/anycable/rpc/**/*'
|
16
|
-
- 'Rakefile'
|
17
13
|
- 'Gemfile'
|
14
|
+
- 'Rakefile'
|
15
|
+
- '*.gemspec'
|
18
16
|
DisplayCopNames: true
|
19
17
|
StyleGuideCopsOnly: false
|
20
|
-
TargetRubyVersion: 2.
|
21
|
-
|
22
|
-
Style/AccessorMethodName:
|
23
|
-
Enabled: false
|
18
|
+
TargetRubyVersion: 2.4
|
24
19
|
|
25
|
-
|
20
|
+
Rails:
|
26
21
|
Enabled: false
|
27
22
|
|
28
23
|
Style/Documentation:
|
29
24
|
Exclude:
|
30
25
|
- 'spec/**/*.rb'
|
31
26
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
Style/FormatStringToken:
|
36
|
-
Enabled: false
|
27
|
+
Naming/FileName:
|
28
|
+
Exclude:
|
29
|
+
- 'lib/anycable-rails.rb'
|
37
30
|
|
38
31
|
Style/StringLiterals:
|
39
|
-
|
32
|
+
EnforcedStyle: double_quotes
|
40
33
|
|
41
34
|
Style/RegexpLiteral:
|
42
35
|
Enabled: false
|
43
36
|
|
44
|
-
Style/
|
37
|
+
Style/FormatStringToken:
|
38
|
+
Enabled: false
|
39
|
+
|
40
|
+
Layout/SpaceInsideStringInterpolation:
|
45
41
|
EnforcedStyle: no_space
|
46
42
|
|
47
43
|
Style/BlockDelimiters:
|
48
44
|
Exclude:
|
49
45
|
- 'spec/**/*.rb'
|
50
46
|
|
51
|
-
Style/PercentLiteralDelimeters:
|
52
|
-
Enabled: false
|
53
|
-
|
54
|
-
Lint/ScriptPermission:
|
55
|
-
Enabled: false
|
56
|
-
|
57
|
-
Lint/AmbiguousRegexpLiteral:
|
58
|
-
Enabled: false
|
59
|
-
|
60
47
|
Metrics/MethodLength:
|
61
48
|
Exclude:
|
62
49
|
- 'spec/**/*.rb'
|
@@ -66,18 +53,21 @@ Metrics/LineLength:
|
|
66
53
|
Exclude:
|
67
54
|
- 'spec/**/*.rb'
|
68
55
|
|
56
|
+
Metrics/AbcSize:
|
57
|
+
Exclude:
|
58
|
+
- 'spec/**/*.rb'
|
59
|
+
|
69
60
|
Metrics/BlockLength:
|
70
61
|
Exclude:
|
71
62
|
- 'spec/**/*.rb'
|
72
63
|
|
73
|
-
|
64
|
+
Metrics/CyclomaticComplexity:
|
74
65
|
Exclude:
|
75
|
-
- '
|
76
|
-
- 'CHANGELOG.md'
|
77
|
-
- 'lib/anycable-rails.rb'
|
66
|
+
- 'spec/**/*.rb'
|
78
67
|
|
79
|
-
|
80
|
-
|
68
|
+
Metrics/PerceivedComplexity:
|
69
|
+
Exclude:
|
70
|
+
- 'spec/**/*.rb'
|
81
71
|
|
82
|
-
|
83
|
-
Enabled: false
|
72
|
+
Lint/HandleExceptions:
|
73
|
+
Enabled: false
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,35 @@
|
|
1
1
|
# Change log
|
2
2
|
|
3
|
-
##
|
3
|
+
## 0.6.0-dev
|
4
|
+
|
5
|
+
- [PR #56](https://github.com/anycable/anycable-rails/pull/56) Request verification based on ActionCable config. ([@DmitryTsepelev][])
|
6
|
+
|
7
|
+
- Add WS server session ID to log tags if present. ([@palkan][])
|
8
|
+
|
9
|
+
- Support tagged logging. ([@palkan][])
|
10
|
+
|
11
|
+
- Action Cable monkey-patches are only loaded in the context of AnyCable CLI. ([@palkan][])
|
12
|
+
|
13
|
+
No need to think about `requie` and `group` for `anycable-rails`, just add it to Gemfile.
|
14
|
+
|
15
|
+
- Add `:any_cable` subscription adapter for Action Cable. ([@palkan][])
|
16
|
+
|
17
|
+
Use `:any_cable` adapter for Action Cable to broadcast data to AnyCable.
|
18
|
+
|
19
|
+
No more `pubsub` monkey-patches 🎉.
|
20
|
+
|
21
|
+
- Added Rails executor/reloader support. ([@palkan][])
|
22
|
+
|
23
|
+
- **[Breaking]** No more generators. ([@palkan][])
|
24
|
+
|
25
|
+
No need to generate AnyCable runner script since `anycable` gem ships with
|
26
|
+
the CLI.
|
27
|
+
|
28
|
+
- Add dynamic (`AnyCable::CompatibilityError`) compatibility checks. ([@DmitryTsepelev][])
|
29
|
+
|
30
|
+
- Added static (RuboCop) compatibility checks. ([@DmitryTsepelev][])
|
31
|
+
|
32
|
+
See https://github.com/anycable/anycable-rails/issues/52
|
4
33
|
|
5
34
|
## 0.5.4 (2018-06-13)
|
6
35
|
|
@@ -58,3 +87,4 @@ Ignore tagged logger features ('cause we do not have _persistent_ logger).
|
|
58
87
|
|
59
88
|
[@palkan]: https://github.com/palkan
|
60
89
|
[@alekseyl]: https://github.com/alekseyl
|
90
|
+
[@DmitryTsepelev]: https://github.com/DmitryTsepelev
|
data/README.md
CHANGED
@@ -1,152 +1,107 @@
|
|
1
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)
|
2
2
|
[![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/#using_with_rails)
|
3
4
|
|
4
|
-
#
|
5
|
+
# AnyCable Rails
|
5
6
|
|
6
|
-
AnyCable allows you to use any WebSocket server (written in any language) as a replacement for built-in Rails
|
7
|
+
AnyCable allows you to use any WebSocket server (written in any language) as a replacement for built-in Rails Action Cable server.
|
7
8
|
|
8
|
-
With AnyCable you can use channels, client-side JS, broadcasting - (almost) all that you can do with
|
9
|
+
With AnyCable you can use channels, client-side JS, broadcasting - (almost) all that you can do with Action Cable.
|
9
10
|
|
10
|
-
You can even use
|
11
|
+
You can even use Action Cable in development and not be afraid of [compatibility issues](#compatibility).
|
11
12
|
|
12
|
-
[Example Application](https://github.com/anycable/anycable_demo)
|
13
|
+
💾 [Example Application](https://github.com/anycable/anycable_demo)
|
14
|
+
|
15
|
+
📑 [Documentation](https://docs.anycable.io).
|
13
16
|
|
14
|
-
For usage outside Rails see [AnyCable repository](https://github.com/anycable/anycable).
|
15
17
|
|
16
18
|
<a href="https://evilmartians.com/">
|
17
19
|
<img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg" alt="Sponsored by Evil Martians" width="236" height="54"></a>
|
18
20
|
|
19
21
|
## Requirements
|
20
22
|
|
21
|
-
- Ruby ~> 2.
|
23
|
+
- Ruby ~> 2.4;
|
22
24
|
- Rails ~> 5.0;
|
23
|
-
- Redis
|
25
|
+
- Redis (see [other options]() for broadcasting)
|
24
26
|
|
25
27
|
## How It Works?
|
26
28
|
|
27
29
|
<img src="https://trello-attachments.s3.amazonaws.com/5781e0ed48e4679e302833d3/820x987/5b6a305417b04e20e75f49c5816e027c/Anycable_vs_ActionCable_copy.jpg" width="400" />
|
28
30
|
|
29
|
-
##
|
30
|
-
|
31
|
-
- [GitPitch Slides](https://gitpitch.com/anycable/anycable/master?grs=github)
|
32
|
-
|
33
|
-
- RailsClub Moscow 2016 [slides](https://speakerdeck.com/palkan/railsclub-moscow-2016-anycable) and [video](https://www.youtube.com/watch?v=-k7GQKuBevY&list=PLiWUIs1hSNeOXZhotgDX7Y7qBsr24cu7o&index=4) (RU)
|
34
|
-
|
35
|
-
|
36
|
-
## Compatible WebSocket servers
|
37
|
-
|
38
|
-
- [Anycable Go](https://github.com/anycable/anycable-go)
|
39
|
-
- [ErlyCable](https://github.com/anycable/erlycable)
|
40
|
-
|
31
|
+
## Usage
|
41
32
|
|
42
|
-
## Installation
|
43
33
|
|
44
|
-
Add
|
34
|
+
Add `anycable-rails` gem to your Gemfile:
|
45
35
|
|
46
36
|
```ruby
|
47
|
-
gem
|
37
|
+
gem "anycable-rails"
|
48
38
|
|
49
|
-
#
|
50
|
-
|
51
|
-
gem 'anycable-rails', group: :production
|
39
|
+
# when using Redis broadcast adapter
|
40
|
+
gem "redis", ">= 4.0"
|
52
41
|
```
|
53
42
|
|
54
|
-
|
55
|
-
make sure that it's loaded prior to `Rails.application.initialize!` call (see `config/environment.rb`).
|
43
|
+
(and don't forget to run `bundle install`).
|
56
44
|
|
57
|
-
|
45
|
+
Next, specify AnyCable subscription adapter for Action Cable:
|
58
46
|
|
59
|
-
```
|
60
|
-
|
47
|
+
```yml
|
48
|
+
# config/cable.yml
|
49
|
+
production:
|
50
|
+
adapter: any_cable
|
61
51
|
```
|
62
52
|
|
63
|
-
|
53
|
+
and specify AnyCable WebSocket server URL:
|
64
54
|
|
65
|
-
|
55
|
+
```ruby
|
56
|
+
# For development it's likely the localhost
|
66
57
|
|
67
|
-
|
58
|
+
# config/environments/development.rb
|
59
|
+
config.action_cable.url = "ws://localhost:3334/cable"
|
68
60
|
|
69
|
-
|
70
|
-
production:
|
71
|
-
# gRPC server host
|
72
|
-
rpc_host: "localhost:50051"
|
73
|
-
# Redis URL (for broadcasting)
|
74
|
-
redis_url: "redis://localhost:6379/2"
|
75
|
-
# Redis channel name
|
76
|
-
redis_channel: "anycable"
|
61
|
+
# For production it's likely to have a sub-domain and secure connection
|
77
62
|
|
63
|
+
# config/environments/production.rb
|
64
|
+
config.action_cable.url = "wss://ws.example.com/cable"
|
78
65
|
```
|
79
66
|
|
80
|
-
|
67
|
+
hen, run AnyCable RPC server:
|
81
68
|
|
82
|
-
|
69
|
+
```ruby
|
70
|
+
$ bundle exec anycable
|
83
71
|
|
84
|
-
|
72
|
+
# don't forget to provide Rails env
|
85
73
|
|
86
|
-
|
87
|
-
RAILS_ENV=production ./bin/anycable
|
74
|
+
$ RAILS_ENV=production bundle exec anycable
|
88
75
|
```
|
89
76
|
|
90
|
-
|
77
|
+
And, finally, run AnyCable WebSocket server, e.g. [anycable-go](https://docs.anycable.io/#go_getting_started.md):
|
91
78
|
|
92
79
|
```sh
|
93
80
|
anycable-go --host=localhost --port=3334
|
94
81
|
```
|
95
82
|
|
96
|
-
|
83
|
+
See [documentation](https://docs.anycable.io/#using_with_rails) for more information on AnyCable + Rails usage.
|
97
84
|
|
98
|
-
|
99
|
-
# For development it's likely the localhost
|
85
|
+
## Action Cable Compatibility
|
100
86
|
|
101
|
-
|
102
|
-
config.action_cable.url = "ws://localhost:3334/cable"
|
87
|
+
See [documentation](https://docs.anycable.io/#compatibility).
|
103
88
|
|
104
|
-
|
105
|
-
|
106
|
-
# config/environments/production.rb
|
107
|
-
config.action_cable.url = "wss://ws.example.com/cable"
|
108
|
-
```
|
89
|
+
## Links
|
109
90
|
|
110
|
-
|
91
|
+
- [AnyCable: Action Cable on steroids!](https://evilmartians.com/chronicles/anycable-actioncable-on-steroids)
|
111
92
|
|
112
|
-
|
93
|
+
- [From Action to Any](https://medium.com/@leshchuk/from-action-to-any-1e8d863dd4cf) by [@alekseyl](https://github.com/alekseyl)
|
113
94
|
|
114
|
-
|
115
|
-
# in Rails configuration
|
116
|
-
if Anycable.config.debug
|
117
|
-
config.logger = Logger.new(STDOUT)
|
118
|
-
config.log_level = :debug
|
119
|
-
end
|
120
|
-
```
|
95
|
+
## Talks
|
121
96
|
|
122
|
-
|
97
|
+
- 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)
|
123
98
|
|
124
|
-
|
125
|
-
# in anycable.yml
|
126
|
-
production:
|
127
|
-
access_logs_disabled: false
|
128
|
-
```
|
99
|
+
- 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)
|
129
100
|
|
130
|
-
##
|
131
|
-
|
132
|
-
This is the compatibility list for the AnyCable gem, not for AnyCable servers (which may not support some of the features yet).
|
133
|
-
|
134
|
-
Feature | Status
|
135
|
-
-------------------------|--------
|
136
|
-
Connection Identifiers | +
|
137
|
-
Connection Request (cookies, params) | +
|
138
|
-
Disconnect Handling | +
|
139
|
-
Subscribe to channels | +
|
140
|
-
Parameterized subscriptions | +
|
141
|
-
Unsubscribe from channels | +
|
142
|
-
[Subscription Instance Variables](http://edgeapi.rubyonrails.org/classes/ActionCable/Channel/Streams.html) | -
|
143
|
-
Performing Channel Actions | +
|
144
|
-
Streaming | +
|
145
|
-
[Custom stream callbacks](http://edgeapi.rubyonrails.org/classes/ActionCable/Channel/Streams.html) | -
|
146
|
-
Broadcasting | +
|
147
|
-
Periodical Timers | -
|
148
|
-
Disconnect remote clients | -
|
101
|
+
## Compatible WebSocket servers
|
149
102
|
|
103
|
+
- [AnyCable Go](https://github.com/anycable/anycable-go)
|
104
|
+
- [ErlyCable](https://github.com/anycable/erlycable)
|
150
105
|
|
151
106
|
## Contributing
|
152
107
|
|
data/Rakefile
CHANGED
@@ -2,7 +2,12 @@ require "bundler/gem_tasks"
|
|
2
2
|
require "rspec/core/rake_task"
|
3
3
|
require "rubocop/rake_task"
|
4
4
|
|
5
|
-
RSpec::Core::RakeTask.new(:spec)
|
6
5
|
RuboCop::RakeTask.new
|
7
6
|
|
8
|
-
|
7
|
+
desc "Run compatibility specs"
|
8
|
+
RSpec::Core::RakeTask.new("spec:compatibility") do |task|
|
9
|
+
task.pattern = "spec/**/*_compatibility.rb"
|
10
|
+
task.verbose = false
|
11
|
+
end
|
12
|
+
|
13
|
+
task default: %w[rubocop spec:compatibility spec]
|
data/anycable-rails.gemspec
CHANGED
@@ -6,7 +6,7 @@ require 'anycable/rails/version'
|
|
6
6
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
8
|
spec.name = "anycable-rails"
|
9
|
-
spec.version =
|
9
|
+
spec.version = AnyCable::Rails::VERSION
|
10
10
|
spec.authors = ["palkan"]
|
11
11
|
spec.email = ["dementiev.vm@gmail.com"]
|
12
12
|
|
@@ -19,12 +19,12 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.add_dependency "rails", ">= 5"
|
22
|
-
spec.add_dependency "anycable", "
|
22
|
+
spec.add_dependency "anycable", "0.6.0.rc1"
|
23
23
|
|
24
24
|
spec.add_development_dependency "bundler", "~> 1"
|
25
25
|
spec.add_development_dependency "rake", "~> 10.0"
|
26
26
|
spec.add_development_dependency "rspec", ">= 3.4"
|
27
|
-
spec.add_development_dependency "
|
27
|
+
spec.add_development_dependency "sqlite3"
|
28
28
|
spec.add_development_dependency "simplecov", ">= 0.3.8"
|
29
29
|
spec.add_development_dependency "rubocop", "~> 0.60.0"
|
30
30
|
spec.add_development_dependency "pry-byebug"
|