README.md in rails_failover-0.8.1 vs README.md in rails_failover-1.0.0
- old
+ new
@@ -1,11 +1,11 @@
# RailsFailover
Automatic failover and recovery for primary/replica setup for:
1. Redis
-1. ActiveRecord (PostgreSQL/MySQL Adapters)
+2. ActiveRecord (PostgreSQL/MySQL Adapters)
## Installation
Add this line to your application's Gemfile:
@@ -27,23 +27,23 @@
In `config/application.rb` add `require 'rails_failover/active_record'` after `require "active_record/railtie"`.
In your database configuration, simply add `replica_host` and `replica_port` to your database configuration.
-```
+```yml
production:
host: <primary db server host>
port: <primary db server port>
replica_host: <replica db server host>
replica_port: <replica db server port>
```
-The gem will automatically create an `ActiveRecord::ConnectionAdapters::ConnectionHandler` with the `ActiveRecord::Base.reading_role` as the `handler_key`.
+The gem will automatically create an `ActiveRecord::ConnectionAdapters::ConnectionHandler` with the `ActiveRecord.reading_role` as the `handler_key`.
#### Failover/Fallback Hooks
-```
+```ruby
RailsFailover::ActiveRecord.on_failover do
# Enable readonly mode
end
RailsFailover::ActiveRecord.on_fallback do
@@ -53,11 +53,11 @@
#### Multiple connection handlers
Note: This API is unstable and is likely to change when Rails 6.1 is released with sharding support.
-```
+```yml
# config/database.yml
production:
primary:
host: <primary db server host>
@@ -77,17 +77,17 @@
### Redis
Add `require 'rails_failover/redis'` before creating a `Redis` instance.
+```ruby
+Redis.new(host: "127.0.0.1", port: 6379, replica_host: "127.0.0.1", replica_port: 6380, connector: RailsFailover::Redis::Connector)
```
-Redis.new(host: "127.0.0.1", port: 6379, replica_host: "127.0.0.1", replica_port: 6380, connector: RailsFailover::Redis::Connector))
-```
Callbacks can be registered when the primary connection is down and when it is up.
-```
+```ruby
RailsFailover::Redis.on_failover_callback do
# Switch site to read-only mode
end
RailsFailover::Redis.on_fallback_callback do
@@ -106,11 +106,11 @@
#### ActiveRecord
The ActiveRecord failover tests are run against a dummy Rails server. Run the following commands to run the test:
1. `make setup_pg`
-1. `make start_pg`
-1. `bin/rspec active_record`. You may also run the tests with more unicorn workers by adding the `UNICORN_WORKERS` env variable.
+2. `make start_pg`
+3. `bin/rspec active_record`. You may also run the tests with more unicorn workers by adding the `UNICORN_WORKERS` env variable.
#### Redis
`bin/rspec redis`