anycable-rails 1.4.0 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +18 -0
  3. metadata +10 -58
  4. data/lib/action_cable/subscription_adapter/any_cable.rb +0 -40
  5. data/lib/action_cable/subscription_adapter/anycable.rb +0 -10
  6. data/lib/anycable/rails/action_cable_ext/channel.rb +0 -51
  7. data/lib/anycable/rails/action_cable_ext/connection.rb +0 -90
  8. data/lib/anycable/rails/action_cable_ext/remote_connections.rb +0 -13
  9. data/lib/anycable/rails/channel_state.rb +0 -108
  10. data/lib/anycable/rails/compatibility/rubocop/config/default.yml +0 -14
  11. data/lib/anycable/rails/compatibility/rubocop/cops/anycable/instance_vars.rb +0 -50
  12. data/lib/anycable/rails/compatibility/rubocop/cops/anycable/periodical_timers.rb +0 -29
  13. data/lib/anycable/rails/compatibility/rubocop/cops/anycable/stream_from.rb +0 -100
  14. data/lib/anycable/rails/compatibility/rubocop.rb +0 -27
  15. data/lib/anycable/rails/compatibility.rb +0 -63
  16. data/lib/anycable/rails/config.rb +0 -19
  17. data/lib/anycable/rails/connection.rb +0 -211
  18. data/lib/anycable/rails/connection_factory.rb +0 -44
  19. data/lib/anycable/rails/connections/persistent_session.rb +0 -40
  20. data/lib/anycable/rails/connections/serializable_identification.rb +0 -46
  21. data/lib/anycable/rails/connections/session_proxy.rb +0 -81
  22. data/lib/anycable/rails/middlewares/executor.rb +0 -31
  23. data/lib/anycable/rails/middlewares/log_tagging.rb +0 -21
  24. data/lib/anycable/rails/rack.rb +0 -56
  25. data/lib/anycable/rails/railtie.rb +0 -92
  26. data/lib/anycable/rails/version.rb +0 -7
  27. data/lib/anycable/rails.rb +0 -76
  28. data/lib/anycable-rails.rb +0 -3
  29. data/lib/generators/anycable/download/USAGE +0 -14
  30. data/lib/generators/anycable/download/download_generator.rb +0 -85
  31. data/lib/generators/anycable/setup/USAGE +0 -2
  32. data/lib/generators/anycable/setup/setup_generator.rb +0 -300
  33. data/lib/generators/anycable/setup/templates/Procfile.dev.tt +0 -6
  34. data/lib/generators/anycable/setup/templates/config/anycable.yml.tt +0 -48
  35. data/lib/generators/anycable/setup/templates/config/cable.yml.tt +0 -11
  36. data/lib/generators/anycable/setup/templates/config/initializers/anycable.rb.tt +0 -9
  37. data/lib/generators/anycable/with_os_helpers.rb +0 -55
@@ -1,92 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "anycable/rails/action_cable_ext/connection"
4
- require "anycable/rails/action_cable_ext/channel"
5
- require "anycable/rails/action_cable_ext/remote_connections"
6
-
7
- require "anycable/rails/channel_state"
8
- require "anycable/rails/connection_factory"
9
-
10
- module AnyCable
11
- module Rails
12
- class Railtie < ::Rails::Railtie # :nodoc:
13
- initializer "anycable.disable_action_cable_mount", after: "action_cable.set_configs" do |app|
14
- next unless AnyCable::Rails.enabled?
15
-
16
- app.config.action_cable.mount_path = nil
17
- end
18
-
19
- initializer "anycable.logger", after: "action_cable.logger" do |_app|
20
- AnyCable.logger = ::ActionCable.server.config.logger
21
-
22
- AnyCable.configure_server do
23
- server_logger = AnyCable.logger = ::ActionCable.server.config.logger
24
- AnyCable.logger = ActiveSupport::TaggedLogging.new(server_logger) if server_logger.is_a?(::Logger)
25
- # Broadcast server logs to STDOUT in development
26
- if ::Rails.env.development? &&
27
- !ActiveSupport::Logger.logger_outputs_to?(::Rails.logger, $stdout)
28
- console = ActiveSupport::Logger.new($stdout)
29
- console.formatter = ::Rails.logger.formatter if ::Rails.logger.respond_to?(:formatter)
30
- console.level = ::Rails.logger.level if ::Rails.logger.respond_to?(:level)
31
- AnyCable.logger.extend(ActiveSupport::Logger.broadcast(console))
32
- end
33
- end
34
-
35
- # Add tagging middleware
36
- if AnyCable.logger.respond_to?(:tagged)
37
- require "anycable/rails/middlewares/log_tagging"
38
-
39
- AnyCable.middleware.use(AnyCable::Rails::Middlewares::LogTagging)
40
- end
41
- end
42
-
43
- initializer "anycable.executor" do |app|
44
- require "anycable/rails/middlewares/executor"
45
- # see https://github.com/rails/rails/pull/33469/files
46
- executor = app.config.reload_classes_only_on_change ? app.reloader : app.executor
47
- AnyCable.middleware.use(AnyCable::Rails::Middlewares::Executor.new(executor))
48
-
49
- if app.executor.respond_to?(:error_reporter)
50
- AnyCable.capture_exception do |ex, method, message|
51
- ::Rails.error.report(ex, handled: false, context: {method: method.to_sym, payload: message})
52
- end
53
- end
54
- end
55
-
56
- initializer "anycable.connection_factory", after: "action_cable.set_configs" do |app|
57
- ActiveSupport.on_load(:action_cable) do
58
- app.config.to_prepare do
59
- AnyCable.connection_factory = AnyCable::Rails::ConnectionFactory.new
60
- end
61
-
62
- if AnyCable.config.persistent_session_enabled?
63
- require "anycable/rails/connections/persistent_session"
64
- end
65
- end
66
- end
67
-
68
- initializer "anycable.routes" do
69
- next unless AnyCable::Rails.enabled?
70
-
71
- config.after_initialize do |app|
72
- config = AnyCable.config
73
- unless config.http_rpc_mount_path.nil?
74
- app.routes.prepend do
75
- mount AnyCable::HTTRPC::Server.new => config.http_rpc_mount_path, :internal => true
76
- end
77
- end
78
- end
79
- end
80
-
81
- # Since Rails 6.1
82
- if respond_to?(:server)
83
- server do
84
- next unless AnyCable.config.embedded? && AnyCable::Rails.enabled?
85
-
86
- require "anycable/cli"
87
- AnyCable::CLI.embed!
88
- end
89
- end
90
- end
91
- end
92
- end
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module AnyCable
4
- module Rails
5
- VERSION = "1.4.0"
6
- end
7
- end
@@ -1,76 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "anycable"
4
- require "anycable/rails/version"
5
- require "anycable/rails/config"
6
- require "anycable/rails/rack"
7
-
8
- require "globalid"
9
-
10
- module AnyCable
11
- # Rails handler for AnyCable
12
- module Rails
13
- require "anycable/rails/railtie"
14
-
15
- ADAPTER_ALIASES = %w[any_cable anycable].freeze
16
-
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
51
-
52
- module Extension
53
- def broadcast(channel, payload)
54
- super
55
- ::AnyCable.broadcast(channel, payload)
56
- end
57
- end
58
-
59
- def extend_adapter!(adapter)
60
- adapter.extend(Extension)
61
- end
62
- end
63
- end
64
- end
65
-
66
- # Warn if application has been already initialized.
67
- # AnyCable should be loaded before initialization in order to work correctly.
68
- if defined?(::Rails) && ::Rails.application && ::Rails.application.initialized?
69
- puts("\n**************************************************")
70
- puts(
71
- "⛔️ WARNING: AnyCable loaded after application initialization. Might not work correctly.\n" \
72
- "Please, make sure to remove `require: false` in your Gemfile or " \
73
- "require manually in `environment.rb` before `Rails.application.initialize!`"
74
- )
75
- puts("**************************************************\n\n")
76
- end
@@ -1,3 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "anycable/rails"
@@ -1,14 +0,0 @@
1
- Description:
2
- Install AnyCable-Go web server locally (the latest version by default).
3
-
4
- Example:
5
- rails generate anycable:download
6
-
7
- This will ask:
8
- Where to store a binary file.
9
- This will create:
10
- `<bin_path>/anycable-go`.
11
-
12
- rails generate anycable:download --bin-path=/usr/local/bin
13
-
14
- rails generate anycable:download --version=1.0.0
@@ -1,85 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "generators/anycable/with_os_helpers"
4
-
5
- module AnyCableRailsGenerators
6
- # Downloads anycable-go binary
7
- class DownloadGenerator < ::Rails::Generators::Base
8
- namespace "anycable:download"
9
-
10
- include WithOSHelpers
11
-
12
- VERSION = "latest"
13
-
14
- class_option :bin_path,
15
- type: :string,
16
- desc: "Where to download AnyCable-Go server binary (default: #{DEFAULT_BIN_PATH})"
17
- class_option :version,
18
- type: :string,
19
- desc: "Specify the AnyCable-Go version (defaults to latest release)"
20
-
21
- def download_bin
22
- out = options[:bin_path] || DEFAULT_BIN_PATH
23
- version = options[:version] || VERSION
24
-
25
- download_exe(
26
- release_url(version),
27
- to: out,
28
- file_name: "anycable-go"
29
- )
30
-
31
- true
32
- end
33
-
34
- private
35
-
36
- def release_url(version)
37
- return latest_release_url(version) if version == "latest"
38
-
39
- if Gem::Version.new(version).segments.first >= 1
40
- new_release_url("v#{version}")
41
- else
42
- legacy_release_url("v#{version}")
43
- end
44
- end
45
-
46
- def legacy_release_url(version)
47
- "https://github.com/anycable/anycable-go/releases/download/#{version}/" \
48
- "anycable-go-v#{version}-#{os_name}-#{cpu_name}"
49
- end
50
-
51
- def new_release_url(version)
52
- "https://github.com/anycable/anycable-go/releases/download/#{version}/" \
53
- "anycable-go-#{os_name}-#{cpu_name}"
54
- end
55
-
56
- def latest_release_url(version)
57
- "https://github.com/anycable/anycable-go/releases/latest/download/" \
58
- "anycable-go-#{os_name}-#{cpu_name}"
59
- end
60
-
61
- def download_exe(url, to:, file_name:)
62
- file_path = File.join(to, file_name)
63
-
64
- FileUtils.mkdir_p(to) unless File.directory?(to)
65
-
66
- run "#{sudo(to)}curl -L #{url} -o #{file_path}", abort_on_failure: true
67
- run "#{sudo(to)}chmod +x #{file_path}", abort_on_failure: true
68
- run "#{file_path} -v", abort_on_failure: true
69
- end
70
-
71
- def sudo(path)
72
- sudo = ""
73
- unless File.writable?(path)
74
- if yes? "Path is not writable 😕. Do you have sudo privileges?"
75
- sudo = "sudo "
76
- else
77
- say_status :error, "❌ Failed to install AnyCable-Go WebSocket server", :red
78
- raise StandardError, "Path #{path} is not writable!"
79
- end
80
- end
81
-
82
- sudo
83
- end
84
- end
85
- end
@@ -1,2 +0,0 @@
1
- Description:
2
- Configures your application to work with AnyCable interactively.
@@ -1,300 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "generators/anycable/with_os_helpers"
4
-
5
- module AnyCableRailsGenerators
6
- # Entry point for interactive installation
7
- class SetupGenerator < ::Rails::Generators::Base
8
- namespace "anycable:setup"
9
- source_root File.expand_path("templates", __dir__)
10
-
11
- DOCS_ROOT = "https://docs.anycable.io"
12
- DEVELOPMENT_METHODS = %w[skip local docker].freeze
13
- SERVER_SOURCES = %w[skip brew binary].freeze
14
-
15
- class_option :devenv,
16
- type: :string,
17
- desc: "Select your development environment (options: #{DEVELOPMENT_METHODS.join(", ")})"
18
- class_option :source,
19
- type: :string,
20
- desc: "Choose a way of installing AnyCable-Go server (options: #{SERVER_SOURCES.join(", ")})"
21
- class_option :skip_heroku,
22
- type: :boolean,
23
- desc: "Do not copy Heroku configs"
24
- class_option :skip_procfile_dev,
25
- type: :boolean,
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"
33
-
34
- include WithOSHelpers
35
-
36
- class_option :bin_path,
37
- type: :string,
38
- desc: "Where to download AnyCable-Go server binary (default: #{DEFAULT_BIN_PATH})"
39
- class_option :version,
40
- type: :string,
41
- desc: "Specify the AnyCable-Go version (defaults to latest release)"
42
-
43
- def welcome
44
- say "👋 Welcome to AnyCable interactive installer."
45
- end
46
-
47
- def configs
48
- inside("config") do
49
- template "cable.yml"
50
- template "anycable.yml"
51
- end
52
- end
53
-
54
- def cable_url
55
- environment(nil, env: :development) do
56
- <<~SNIPPET
57
- # Specify AnyCable WebSocket server URL to use by JS client
58
- config.after_initialize do
59
- config.action_cable.url = ActionCable.server.config.url = ENV.fetch("CABLE_URL", "ws://localhost:8080/cable") if AnyCable::Rails.enabled?
60
- end
61
- SNIPPET
62
- end
63
-
64
- environment(nil, env: :production) do
65
- <<~SNIPPET
66
- # Specify AnyCable WebSocket server URL to use by JS client
67
- config.after_initialize do
68
- config.action_cable.url = ActionCable.server.config.url = ENV.fetch("CABLE_URL", "/cable") if AnyCable::Rails.enabled?
69
- end
70
- SNIPPET
71
- end
72
-
73
- say_status :info, "✅ 'config.action_cable.url' has been configured"
74
- say_status :help, "⚠️ If you're using JS client make sure you have " \
75
- "`action_cable_meta_tag` included before any <script> tag in your application.html"
76
- end
77
-
78
- def development_method
79
- answer = DEVELOPMENT_METHODS.index(options[:devenv]) || 99
80
-
81
- until DEVELOPMENT_METHODS[answer.to_i]
82
- answer = ask "Which environment do you use for development? (1) Local, (2) Docker, (0) Skip"
83
- end
84
-
85
- case env = DEVELOPMENT_METHODS[answer.to_i]
86
- when "skip"
87
- say_status :help, "⚠️ Please, read this guide on how to install AnyCable-Go server 👉 #{DOCS_ROOT}/anycable-go/getting_started", :yellow
88
- else
89
- send "install_for_#{env}"
90
- end
91
- end
92
-
93
- def heroku
94
- if options[:skip_heroku].nil?
95
- return unless yes? "Do you use Heroku for deployment? [Yn]"
96
- elsif options[:skip_heroku]
97
- return
98
- end
99
-
100
- in_root do
101
- next unless File.file?("Procfile")
102
-
103
- contents = File.read("Procfile")
104
- contents.sub!(/^web: (.*)$/, %q(web: [[ "$ANYCABLE_DEPLOYMENT" == "true" ]] && bundle exec anycable --server-command="anycable-go" || \1))
105
- File.write("Procfile", contents)
106
- say_status :info, "✅ Procfile updated"
107
- end
108
-
109
- say_status :help, "️️⚠️ Please, read the required steps to configure Heroku applications 👉 #{DOCS_ROOT}/deployment/heroku", :yellow
110
- end
111
-
112
- def devise
113
- in_root do
114
- return unless File.file?("config/initializers/devise.rb")
115
- end
116
-
117
- inside("config/initializers") do
118
- template "anycable.rb"
119
- end
120
-
121
- say_status :info, "✅ config/initializers/anycable.rb with Devise configuration has been added"
122
- end
123
-
124
- def stimulus_reflex
125
- return unless stimulus_reflex?
126
-
127
- say_status :help, "⚠️ Please, check out the documentation on using AnyCable with Stimulus Reflex: #{DOCS_ROOT}/rails/stimulus_reflex"
128
- end
129
-
130
- def rubocop_compatibility
131
- return unless rubocop?
132
-
133
- say_status :info, "🤖 Running static compatibility checks with RuboCop"
134
- res = run "bundle exec rubocop -r 'anycable/rails/compatibility/rubocop' --only AnyCable/InstanceVars,AnyCable/PeriodicalTimers,AnyCable/InstanceVars"
135
- say_status :help, "⚠️ Please, take a look at the icompatibilities above and fix them. See #{DOCS_ROOT}/rails/compatibility" unless res
136
- end
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
-
148
- def finish
149
- say_status :info, "✅ AnyCable has been configured successfully!"
150
- end
151
-
152
- private
153
-
154
- def stimulus_reflex?
155
- !!gemfile_lock&.match?(/^\s+stimulus_reflex\b/)
156
- end
157
-
158
- def redis?
159
- !!gemfile_lock&.match?(/^\s+redis\b/)
160
- end
161
-
162
- def nats?
163
- !!gemfile_lock&.match?(/^\s+nats-pure\b/)
164
- end
165
-
166
- def webpacker?
167
- !!gemfile_lock&.match?(/^\s+webpacker\b/)
168
- end
169
-
170
- def rubocop?
171
- !!gemfile_lock&.match?(/^\s+rubocop\b/)
172
- end
173
-
174
- def gemfile_lock
175
- @gemfile_lock ||= begin
176
- res = nil
177
- in_root do
178
- next unless File.file?("Gemfile.lock")
179
- res = File.read("Gemfile.lock")
180
- end
181
- res
182
- end
183
- end
184
-
185
- def install_for_docker
186
- # Remove localhost from configuraiton
187
- gsub_file "config/anycable.yml", /^.*redis_url:.*localhost[^\n]+\n/, ""
188
-
189
- say_status :help, "️️⚠️ Docker development configuration could vary", :yellow
190
-
191
- say "Here is an example snippet for docker-compose.yml:"
192
- say <<~YML
193
- ─────────────────────────────────────────
194
- ws:
195
- image: anycable/anycable-go:1.2
196
- ports:
197
- - '8080:8080'
198
- environment:
199
- ANYCABLE_HOST: "0.0.0.0"
200
- ANYCABLE_REDIS_URL: redis://redis:6379/0
201
- ANYCABLE_RPC_HOST: anycable:50051
202
- ANYCABLE_DEBUG: 1
203
- depends_on:
204
- redis:
205
- condition: service_healthy
206
-
207
- anycable:
208
- <<: *backend
209
- command: bundle exec anycable
210
- environment:
211
- <<: *backend_environment
212
- ANYCABLE_REDIS_URL: redis://redis:6379/0
213
- ANYCABLE_RPC_HOST: 0.0.0.0:50051
214
- ANYCABLE_DEBUG: 1
215
- ports:
216
- - '50051'
217
- depends_on:
218
- <<: *backend_depends_on
219
- ws:
220
- condition: service_started
221
- ─────────────────────────────────────────
222
- YML
223
- end
224
-
225
- def install_for_local
226
- install_server
227
- template_proc_files
228
- end
229
-
230
- def install_server
231
- answer = SERVER_SOURCES.index(options[:source]) || 99
232
-
233
- until SERVER_SOURCES[answer.to_i]
234
- answer = ask "How do you want to install AnyCable-Go WebSocket server? (1) Homebrew, (2) Download binary, (0) Skip"
235
- end
236
-
237
- case answer.to_i
238
- when 0
239
- say_status :help, "⚠️ Please, read this guide on how to install AnyCable-Go server 👉 #{DOCS_ROOT}/anycable-go/getting_started", :yellow
240
- return
241
- else
242
- return unless send("install_from_#{SERVER_SOURCES[answer.to_i]}")
243
- end
244
-
245
- say_status :info, "✅ AnyCable-Go WebSocket server has been successfully installed"
246
- end
247
-
248
- def template_proc_files
249
- file_name = "Procfile.dev"
250
-
251
- if file_exists?(file_name)
252
- append_file file_name, "anycable: bundle exec anycable\nws: anycable-go#{anycable_go_options}", force: true
253
- else
254
- say_status :help, "💡 We recommend using Hivemind to manage multiple processes in development 👉 https://github.com/DarthSim/hivemind", :yellow
255
-
256
- if options[:skip_procfile_dev].nil?
257
- return unless yes? "Do you want to create a '#{file_name}' file?"
258
- elsif options[:skip_procfile_dev]
259
- return
260
- end
261
-
262
- template file_name
263
- end
264
- end
265
-
266
- def install_from_brew
267
- run "brew install anycable-go", abort_on_failure: true
268
- run "anycable-go -v", abort_on_failure: true
269
- end
270
-
271
- def install_from_binary
272
- bin_path ||= DEFAULT_BIN_PATH if options[:devenv] # User don't want interactive mode
273
- bin_path ||= ask "Please, enter the path to download the AnyCable-Go binary to", default: DEFAULT_BIN_PATH, path: true
274
-
275
- generate "anycable:download", download_options(bin_path: bin_path)
276
-
277
- true
278
- end
279
-
280
- def download_options(**params)
281
- opts = options.merge(params)
282
- [].tap do |args|
283
- args << "--os #{opts[:os]}" if opts[:os]
284
- args << "--cpu #{opts[:cpu]}" if opts[:cpu]
285
- args << "--bin-path=#{opts[:bin_path]}" if opts[:bin_path]
286
- args << "--version #{opts[:version]}" if opts[:version]
287
- end.join(" ")
288
- end
289
-
290
- def anycable_go_options
291
- redis? ? " --port=8080" : " --port=8080 --broadcast_adapter=http"
292
- end
293
-
294
- def file_exists?(name)
295
- in_root do
296
- return File.file?(name)
297
- end
298
- end
299
- end
300
- end
@@ -1,6 +0,0 @@
1
- server: bundle exec rails s
2
- <%- if webpacker? -%>
3
- assets: bundle exec bin/webpack-dev-server
4
- <%- end -%>
5
- anycable: bundle exec anycable
6
- ws: anycable-go<%= anycable_go_options %>
@@ -1,48 +0,0 @@
1
- # This file contains per-environment settings for AnyCable.
2
- #
3
- # Since AnyCable config is based on anyway_config (https://github.com/palkan/anyway_config), all AnyCable settings
4
- # can be set or overridden through the corresponding environment variables.
5
- # E.g., `rpc_host` is overridden by ANYCABLE_RPC_HOST, `debug` by ANYCABLE_DEBUG etc.
6
- #
7
- # Note that AnyCable recognizes REDIS_URL env variable for Redis pub/sub adapter. If you want to
8
- # use another Redis instance for AnyCable, provide ANYCABLE_REDIS_URL variable.
9
- #
10
- # Read more about AnyCable configuration here: <%= DOCS_ROOT %>/ruby/configuration
11
- #
12
- default: &default
13
- # Turn on/off access logs ("Started..." and "Finished...")
14
- access_logs_disabled: false
15
- # Whether to enable gRPC level logging or not
16
- log_grpc: false
17
- <%- if redis? -%>
18
- # Use Redis to broadcast messages to AnyCable server
19
- broadcast_adapter: redis
20
- <%- elsif nats? -%>
21
- # Use NATS to broadcast messages to AnyCable server
22
- broadcast_adapter: nats
23
- <%- else -%>
24
- # Use HTTP adapter for a quick start (since redis gem is not present in the project)
25
- broadcast_adapter: http
26
- <%- end -%>
27
- # Use the same channel name for WebSocket server, e.g.:
28
- # $ anycable-go --redis_channel="__anycable__"
29
- redis_channel: "__anycable__"
30
- <%- if redis? -%>
31
- # You can use REDIS_URL env var to configure Redis URL.
32
- # Localhost is used by default.
33
- # redis_url: "redis://localhost:6379/1"
34
- <%- end -%>
35
-
36
- development:
37
- <<: *default
38
-
39
- test:
40
- <<: *default
41
-
42
- production:
43
- <<: *default
44
- <%- if !redis? && !nats? -%>
45
- # Use Redis or NATS in production
46
- broadcast_adapter: redis
47
- # broadcast_adapter: nats
48
- <%- end -%>
@@ -1,11 +0,0 @@
1
- # Make it possible to switch adapters by passing the ACTION_CABLE_ADAPTER env variable.
2
- # For example, you can use it fallback to the standard Action Cable in staging/review
3
- # environments (by setting `ACTION_CABLE_ADAPTER=redis`).
4
- development:
5
- adapter: <%%= ENV.fetch("ACTION_CABLE_ADAPTER", "any_cable") %>
6
-
7
- test:
8
- adapter: test
9
-
10
- production:
11
- adapter: <%%= ENV.fetch("ACTION_CABLE_ADAPTER", "any_cable") %>
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Add Warden middleware to AnyCable stack to allow accessing
4
- # Devise current user via `env["warden"].user`.
5
- #
6
- # See <%= DOCS_ROOT %>/ruby/authentication
7
- AnyCable::Rails::Rack.middleware.use Warden::Manager do |config|
8
- Devise.warden_config = config
9
- end