2.4.1 • Published 7 years ago

loopback-connector-readsplitmysql v2.4.1

Weekly downloads
142
License
MIT
Repository
github
Last release
7 years ago

loopback-connector-readsplitmysql

This is an entirely compatible fork of the mysql connector module that adds read/write splitting. loopback-connector-mysql is the MySQL connector module for loopback-datasource-juggler.

For complete documentation of the mysql connector, see StrongLoop Documentation | MySQL Connector.

Read/Write splitting allows loopback to take advantage of Read-Replicas by directing all read-only queries to faster read replica slaves, whilst writes are sent to the master database.

Installation

npm install loopback-connector-readsplitmysql --save

Basic use

The read split connector can be used in-place of the latest 2x mysql connector. With no additional configuration it will continue to operate against one master database.

To add a read-replica host, add a readonly object to the settings object. All fields are optional. The database connection options will default to the same as the master connection. To disable the read client, either don't set the readonly options at all or set the writeRatio to 1.

OptionDefaultDescription
readonly.writeRatio0.3The fraction of connectionLimit to dedicate to write connections
readonly.hosthostThe host for read-only queries
readonly.portportThe port for read-only queries
readonly.useruserThe user for read-only queries
readonly.passwordpasswordThe password for read-only queries