Skip to content

feat: read replica support via connects_to role switching#44

Merged
eclectic-coding merged 2 commits into
mainfrom
feat/read-replica-support
May 21, 2026
Merged

feat: read replica support via connects_to role switching#44
eclectic-coding merged 2 commits into
mainfrom
feat/read-replica-support

Conversation

@eclectic-coding
Copy link
Copy Markdown
Owner

Summary

  • Extends the connects_to config option to support automatic role switching: when set to { reading: <role>, writing: <role> }, GET requests are routed to the reading role and mutating requests (POST/DELETE/PATCH) to the writing role via ActiveRecord::Base.connected_to(role:)
  • Any other hash (e.g. { role: :writing }, { shard: :name }) falls through to connected_to directly — existing behaviour is unchanged
  • Adds a dedicated Read replica support section to the README with config examples
  • Completes the Infrastructure roadmap; only Admin audit log remains

Test plan

  • bundle exec rspec spec/controllers/solid_queue_web/application_controller_spec.rb — new controller spec with 8 examples covering passthrough, single-role, and reading/writing role switching (including replica_configured? unit tests)
  • bundle exec rspec spec/requests/solid_queue_web/dashboard_spec.rb — smoke test confirms requests succeed with replica role switching active
  • bundle exec rake — full suite (audit + rubocop + rspec), 214 examples, 0 failures, 100% coverage

🤖 Generated with Claude Code

eclectic-coding and others added 2 commits May 21, 2026 09:19
When connects_to is set to { reading: <role>, writing: <role> }, the engine
automatically routes GET requests to the reading role and mutating requests
to the writing role via ActiveRecord::Base.connected_to(role:). Any other
hash (e.g. { role: :writing }) falls through to connected_to directly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@eclectic-coding eclectic-coding merged commit 4577c3a into main May 21, 2026
5 checks passed
@eclectic-coding eclectic-coding deleted the feat/read-replica-support branch May 21, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant