feat(rain): add drizzle-like read replica routing#26
Conversation
Greptile SummaryThis PR adds drizzle-style read replica routing to rain ORM. Key design decisions:
The implementation is clean and the test suite is thorough, covering validation, default/custom selectors, primary views, relation loading, writes, transactions, raw SQL, cache sharing, close idempotency, and concurrent reads. One P2 concern: Confidence Score: 4/5Safe to merge after addressing or documenting the replica QueryCache overwrite behaviour. All routing logic is correct and well-tested. The single remaining concern is a P2 API footgun: pre-configured QueryCache on replica handles is silently discarded by WithReplicas. This won't break users who follow the intended pattern (set cache post-construction on the routed handle), but could surprise users who configure replicas individually before composing them. A doc comment fix is sufficient. pkg/rain/rain.go — specifically the WithReplicas function and its interaction with pre-configured replica shared state. Important Files Changed
|
544f1cb to
4fcd961
Compare
What this PR for?
Add WithReplicas and Primary() to route builder-based reads to replicas while keeping writes, raw SQL, and transactions on primary. Includes sqlite-backed routing tests and docs/examples for replica reads, forced primary reads, and custom selector behavior.
What did you do for validating the changes?
Anything else you want to add? (Optional)