feat(db): offer read replica connection on tiger db connect#165
Merged
Conversation
When running `tiger db connect`/`psql` in an interactive terminal, prompt the user to connect to a read replica instead of the primary, or to create a new read replica and connect to it when none exist. The prompt is skipped when stdin is not a TTY or when `--no-replica-prompt` is passed. Details: - Detect replicas via the `/replicaSets` API; list active ones in a menu. - Read replicas share the primary's credentials, so password storage and recovery operate on the primary service. - After a replica becomes active, wait for its endpoint to accept TCP connections before handing off to psql (avoids a transient "connection refused" race). - `--pooled` is strict for the primary (hard error if unavailable) and best-effort for replicas (warn and fall back to a direct connection). Refactors `GetConnectionDetails`/`GetReplicaConnectionDetails` onto a shared `buildConnectionDetails` helper and adds `common.WaitForReplicaSet`. Updates README, specs, and CLAUDE.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
e5a5f04 to
52b388d
Compare
Drop the "create a new read replica" option from the `tiger db connect` prompt. The prompt now only appears when the service has one or more active read replicas, offering to connect to the primary or one of them; with no replicas it connects to the primary directly without prompting. Removes the replica-creation flow (createReplicaSet, primaryResources, endpoint-readiness wait) and the now-unused WaitForReplicaSet/poll abstraction, reverting wait.go to its prior form. Also simplifies the selection menu to a single source of truth for choices. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
52b388d to
3344e3e
Compare
Askir
approved these changes
Jun 17, 2026
Askir
left a comment
Contributor
There was a problem hiding this comment.
Looks good over all just a bit confused over the pooler behaviour.
Comment on lines
+83
to
+84
| // --pooled is best-effort on replicas: warn and connect directly if the | ||
| // chosen replica has no pooler. |
Contributor
There was a problem hiding this comment.
Is there a particular reason for why we do it this way for replicas? Sorry not super familiar with connection poolers in general.
Contributor
Author
There was a problem hiding this comment.
For the primary, --pooled is the explicit request, so we fail hard if it's unavailable (unchanged behavior). For a replica, it's just a modifier on the connect action you already chose interactively, so rather than blocking the connection, we warn and fall back to a direct connection.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When tiger db connect / psql runs in an interactive terminal and the service has active read replicas, prompt the user to connect to one instead of the primary. With no replicas, non-TTY stdin, or --no-replica-prompt, it connects to the primary directly as before.
Notes
GetConnectionDetails/GetReplicaConnectionDetailsonto a sharedbuildConnectionDetailshelper.