Commit b574b07
feat(source/postgres): add optional connectTimeout (googleapis#3620)
## Description
Adds an opt-in `connectTimeout` field to the postgres source (requested
in googleapis#2227). Today the source sets no connect timeout, so a server that
accepts the TCP connection but never completes the handshake can block
indefinitely.
When `connectTimeout` is set (a Go duration string, e.g. `"5s"`), it is
applied to pgx's `ConnConfig.ConnectTimeout`. When omitted, nothing is
applied and connection behavior is unchanged — per the discussion on
googleapis#2227 this is intentionally opt-in with **no default**, so existing
users see no change.
## PR Checklist
- [x] Make sure you reviewed
[CONTRIBUTING.md](https://github.com/googleapis/mcp-toolbox/blob/main/CONTRIBUTING.md)
- [x] Make sure to open an issue as a bug/issue before writing your code
(googleapis#2227)
- [x] Ensure the tests and linter pass
- [x] Code coverage does not decrease (added `TestApplyConnectTimeout` +
a YAML-parse case)
- [x] Appropriate docs were updated (postgres source reference)
- [ ] Make sure to add `!` if this involves a breaking change — n/a,
opt-in and non-breaking
**Verification**
```
go test ./internal/sources/postgres/ # ok (incl. new TestApplyConnectTimeout: set → 5s, unset → 0/no timeout, invalid → error)
golangci-lint run ./internal/sources/postgres/... # 0 issues
```
🛠️ Fixes googleapis#2227
---------
Co-authored-by: Yuan Teoh <45984206+Yuan325@users.noreply.github.com>1 parent f3e7ca9 commit b574b07
3 files changed
Lines changed: 57 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| 70 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
60 | 61 | | |
61 | 62 | | |
62 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
63 | 68 | | |
64 | 69 | | |
65 | 70 | | |
66 | 71 | | |
67 | 72 | | |
68 | 73 | | |
69 | 74 | | |
70 | | - | |
| 75 | + | |
71 | 76 | | |
72 | 77 | | |
73 | 78 | | |
| |||
131 | 136 | | |
132 | 137 | | |
133 | 138 | | |
134 | | - | |
| 139 | + | |
135 | 140 | | |
136 | 141 | | |
137 | 142 | | |
| |||
158 | 163 | | |
159 | 164 | | |
160 | 165 | | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
161 | 170 | | |
162 | 171 | | |
163 | 172 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
116 | 142 | | |
117 | 143 | | |
118 | 144 | | |
| |||
177 | 203 | | |
178 | 204 | | |
179 | 205 | | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
180 | 221 | | |
181 | 222 | | |
182 | 223 | | |
| |||
192 | 233 | | |
193 | 234 | | |
194 | 235 | | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
195 | 240 | | |
196 | 241 | | |
197 | 242 | | |
| |||
0 commit comments