Sha256: daec1faf61c8bd4bbb5e7af1d13596fa737bdf0c027c70ebe18aa1e0cce128b9

Contents?: true

Size: 1.58 KB

Versions: 20

Compression:

Stored size: 1.58 KB

Contents

# ActiveReplicas

Allows you to automatically send read-only queries to replica databases; writes will automatically go to the primary and "stick" the request into using the primary for any further queries.

This is heavily inspired by [Kickstarter's `replica_pools`](https://github.com/kickstarter/replica_pools) gem. It seeks to improve on that gem by better interfacing with ActiveRecord's connection pools.

## Installation & usage

ActiveReplicas injects itself into ActiveRecord. To start you'll want to add it to your application's `Gemfile`:

```ruby
gem 'active_replicas'
```

You then need to instruct it as to which connection to use for the primary and which connection(s) to use for the read replicas:

```ruby
# config/initializers/active_replicas.rb
ActiveReplicas::Railtie.hijack_active_record primary: { url: 'mysql2://user@primary/my_app' },
                                             replicas: {
                                               replica0: { url: 'mysql2://user@replica/my_app' }
                                             }
```

**Note**: ActiveReplicas does not do anything automatically. It only injects itself into ActiveRecord when you tell it do so (see above).

## Contributing

Bug reports and pull requests are welcome on [GitHub][]. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.

[GitHub]: https://github.com/dirk/active_replicas

## License

Licensed under the 3-clause BSD license. See [LICENSE](LICENSE) for details.

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
active_replicas-0.4.0 README.md
active_replicas-0.3.2 README.md
active_replicas-0.3.1 README.md
active_replicas-0.3.0 README.md
active_replicas-0.2.9 README.md
active_replicas-0.2.8 README.md
active_replicas-0.2.7 README.md
active_replicas-0.2.6 README.md
active_replicas-0.2.3 README.md
active_replicas-0.2.2 README.md
active_replicas-0.2.1 README.md
active_replicas-0.2.0 README.md
active_replicas-0.1.7 README.md
active_replicas-0.1.6 README.md
active_replicas-0.1.5 README.md
active_replicas-0.1.4 README.md
active_replicas-0.1.3 README.md
active_replicas-0.1.2 README.md
active_replicas-0.1.1 README.md
active_replicas-0.1.0 README.md