Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thruster #35

Draft
wants to merge 2 commits into
base: demo/dockerless
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ gem 'cssbundling-rails'
gem 'jsbundling-rails'
gem 'propshaft'

gem 'anycable-thruster'

group :development, :test do
gem 'debug', '~> 1.9'
# FIXME: Fails with Operation not supported by device - <STDIN> when running within Thruster
gem 'debug', '~> 1.9'#, require: false
gem 'rspec-rails', '~> 6.0'
end

Expand All @@ -32,10 +35,8 @@ end

group :test do
gem 'capybara'
gem 'capybara-thruster'
gem 'cuprite'

# Rack-based AnyCable server implementation
gem 'anycable-rack-server', '~> 0.5'

gem 'test-prof'
end
19 changes: 12 additions & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,18 @@ GEM
anycable-core (1.5.0)
anyway_config (~> 2.2)
google-protobuf (~> 3.25)
anycable-rack-server (0.5.1)
anycable (> 1.0.99, < 2.0)
anyway_config (>= 2.1.0)
connection_pool (~> 2.2)
websocket (~> 1.2)
anycable-rails (1.5.1)
anycable (~> 1.5.0)
anycable-rails-core (= 1.5.1)
anycable-rails-core (1.5.1)
actioncable (>= 6.0)
anycable-core (~> 1.5.0)
globalid
anycable-thruster (0.1.3)
anycable-thruster (0.1.3-aarch64-linux)
anycable-thruster (0.1.3-arm64-darwin)
anycable-thruster (0.1.3-x86_64-darwin)
anycable-thruster (0.1.3-x86_64-linux)
anyway_config (2.6.3)
ruby-next-core (~> 1.0)
ast (2.4.2)
Expand All @@ -112,6 +112,11 @@ GEM
rack-test (>= 0.6.3)
regexp_parser (>= 1.5, < 3.0)
xpath (~> 3.2)
capybara-thruster (0.1.0)
capybara
childprocess (>= 4.0)
puma
childprocess (5.0.0)
concurrent-ruby (1.2.3)
connection_pool (2.4.1)
crass (1.0.6)
Expand Down Expand Up @@ -320,7 +325,6 @@ GEM
diff-lcs (~> 1.3)
parser (>= 3.3.0)
webrick (1.8.1)
websocket (1.2.10)
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
Expand All @@ -339,10 +343,11 @@ PLATFORMS
x86_64-linux

DEPENDENCIES
anycable-rack-server (~> 0.5)
anycable-rails (~> 1.5)
anycable-thruster
bootsnap (>= 1.4.2)
capybara
capybara-thruster
cssbundling-rails
cuprite
daemons (~> 1.3)
Expand Down
3 changes: 1 addition & 2 deletions Procfile.dev
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
server: bundle exec rails s -p 3000
server: ANYCABLE_OPT="--broadcast_adapter=http --presets=broker --rpc_host=http://localhost:3100/_anycable" HTTP_PORT=3000 TARGET_PORT=3100 bundle exec thrust bin/rails s
css: yarn build:css --watch
js: yarn build --watch
ws: bin/anycable-go --port=8080 --broadcast_adapter=http --presets=broker --rpc_host=http://localhost:3000/_anycable
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ bin/setup

## Running

Since you need to run multiple processes (Rails, AnyCable-Go), we recommend using a process manager, e.g., [Hivemind](https://github.com/DarthSim/hivemind):
Run Rails server and all secondary processes (CSS/JS bundling):

```sh
hivemind Procfile.dev
bin/dev
```

Then go to [http://localhost:3000/](http://localhost:3000/) and see the application in action.
Expand Down
28 changes: 3 additions & 25 deletions config/anycable.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,19 @@
# This file contains per-environment settings for AnyCable.
#
# Since AnyCable config is based on anyway_config (https://github.com/palkan/anyway_config), all AnyCable settings
# can be set or overridden through the corresponding environment variables.
# E.g., `rpc_host` is overridden by ANYCABLE_RPC_HOST, `debug` by ANYCABLE_DEBUG etc.
#
# Note that AnyCable recognizes REDIS_URL env variable for Redis pub/sub adapter. If you want to
# use another Redis instance for AnyCable, provide ANYCABLE_REDIS_URL variable.
#
# Read more about AnyCable configuration here: https://docs.anycable.io/#/ruby/configuration
# Read more about AnyCable configuration here: https://docs.anycable.io/ruby/configuration
#
default: &default
# Turn on/off access logs ("Started..." and "Finished...")
access_logs_disabled: false
# Persist "dirty" session between RPC calls (might be required for apps using stimulus_reflex <3.0)
# persistent_session_enabled: true
# This is the host and the port to run AnyCable RPC server on.
# You must configure your WebSocket server to connect to it, e.g.:
# $ anycable-go --rpc-host="<rpc hostname>:50051"
rpc_host: "127.0.0.1:50051"
# Whether to enable gRPC level logging or not
log_grpc: false
# Use HTTP adapter for a quick start (since redis gem is not present in the project)
broadcast_adapter: http
# Use the same channel name for WebSocket server, e.g.:
# $ anycable-go --redis-channel="__anycable__"
redis_channel: "__anycable__"
# WebSocket server URL for clients
websocket_url: "ws://localhost:8080/cable"
websocket_url: "/cable"
http_rpc_mount_path: "/_anycable"

development:
<<: *default
http_rpc_mount_path: "/_anycable"

test:
<<: *default
rpc_pool_size: 5
http_broadcast_url: "http://localhost:3023/_anycable_rack_broadcast"

production:
<<: *default
Expand Down
7 changes: 0 additions & 7 deletions config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@
AnyCable::Rails.extend_adapter!(ActionCable.server.pubsub)
end

# Specify AnyCable WebSocket server URL to use by JS client
config.action_cable.url = "/rack_cable"
# Disable built-in Action Cable
config.action_cable.mount_path = nil
# Run AnyCable Rack server at a custom path
config.any_cable_rack.mount_path = "/rack_cable"

# Settings specified here will take precedence over those in config/application.rb.
config.cache_classes = true

Expand Down
26 changes: 0 additions & 26 deletions spec/system/support/anycable_setup.rb

This file was deleted.

4 changes: 4 additions & 0 deletions spec/system/support/capybara_setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@

# Use fixed server port to configure AnyCable broadcast url
Capybara.server_port = 3023
Capybara.server = :thruster, {debug: ENV["DEBUG"] == "1", env: {
"ANYCABLE_BROADCAST_ADAPTER" => "http",
"ANYCABLE_RPC_HOST" => "http://localhost:#{Capybara.server_port}/_anycable"
}}

Capybara.singleton_class.prepend(Module.new do
attr_accessor :last_used_session
Expand Down
Loading