-
Notifications
You must be signed in to change notification settings - Fork 15
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
support for read replica #18
Comments
This again, definitely sounds like an interesting feature, how would be the ideal api look like for you? |
This is a real good question :) I use raw SQL queries all the time, so not sure if it fulfill all the needs. To come back to the question, I think something inside the connection options, could add additional replica servers. F.e. replicas: [{connectionOptions}, ...] where all values from the parent connectionOptions are used and can be overwritten in the replicas[n].connectionOptions. The other part would be a smart query detector, that is able to determine if a select is made or a write operation (so all read operations can be routed to the replica and all write to the default). As an easier to achieve, 1st iteration, you can let the developer decide when using raw queries, if its a read or write. F.e. with an optional flag (useReplica?: boolean). If no replica is set and Flag is set it should fall back to the master. I hope it helps, and please let me know if you have a smarter solution/idea. |
I'm going on vacation soon, but in June-July I will work on it. |
For my daily work, it would be very nice to have an option to define read replicas.
A possible way can be to add a flag to the query execution, to mark a query as read-only, so it is not needed to have a high amount of logic for this feature. On the other hand side, the developer is able to decide what queries to route to the replica.
The text was updated successfully, but these errors were encountered: