Skip to content

Commit b033b30

Browse files
committed
Improved Rails integration documentation.
1 parent d179982 commit b033b30

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

guides/rails-integration/readme.md

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
This guide explains how to host Rails applications with Falcon.
44

5+
**We strongly recommend using the latest stable release of Rails with Falcon.** The integration is much smoother and you will benefit from the latest features and bug fixes. This guide is primarily intended for users of Rails 8.0 and later.
6+
57
## Integration with Rails
68

79
Because Rails apps are built on top of Rack, they are compatible with Falcon.
@@ -54,24 +56,12 @@ require_relative "config/environment"
5456

5557
## Isolation Level
5658

57-
Rails 7.1 introduced the ability to change its internal isolation level from threads (default) to fibers. When you use `falcon` with Rails, it will automatically set the isolation level to fibers.
58-
59-
Beware that changing the isolation level may increase the utilization of shared resources such as Active Record's connection pool, since you'll likely be running many more fibers than threads. In the future, Rails is likely to adjust connection pool handling so this shouldn't be an issue in practice.
60-
61-
To mitigate the issue in the meantime, you can wrap Active Record calls in a `with_connection` block so they're released at the end of the block, as opposed to the default behavior where Rails keeps the connection checked out until its finished returning the response:
59+
Rails provides the ability to change its internal isolation level from threads (default) to fibers. When you use `falcon` with Rails, it will automatically set the isolation level to fibers.
6260

63-
~~~ ruby
64-
ActiveRecord::Base.connection_pool.with_connection do
65-
Example.find(1)
66-
end
67-
~~~
68-
69-
Alternatively, to retain the default Rails behavior, you can add the following to `config/application.rb` to reset the isolation level to threads, but beware that sharing connections between fibers may result in unexpected errors within Active Record and is not recommended:
61+
## ActionCable
7062

71-
~~~ ruby
72-
config.active_support.isolation_level = :thread
73-
~~~
63+
Falcon fully supports ActionCable with the [`Async::Cable` adapter](https://github.com/socketry/async-cable).
7464

75-
## ActionCable
65+
## ActiveJob
7666

77-
Falcon supports `rack.hijack` and is compatible with ActionCable. If you use the `async` adapter, you should run Falcon in threaded mode, or in forked mode with `--count 1`. Otherwise, your messaging system will be distributed over several processes with no IPC mechanism. You might like to try out [async-redis](https://github.com/socketry/async-redis) as an asynchronous message bus.
67+
Falcon fully supports ActiveJob with the [`Async::Job` adapter](https://github.com/socketry/async-job-adapter-active_job).

0 commit comments

Comments
 (0)