Commit e9f33eb
authored
feat(sqs): htfifo capability poller (Phase 3.D PR 4-B-3a) (#721)
## Summary
Phase 3.D PR 4-B-3a — adds the stateless `htfifo` capability poller that
PR 5's CreateQueue gate consumes. Stacks on the now-merged #715 (PR
4-B-2, partition resolver). This PR is purely additive: new helper file,
new test file, no existing code touched. Next is PR 4-B-3b
(leadership-refusal hook + flag flip).
## What's added
- `adapter/sqs_capability_poller.go`:
- `HTFIFOCapabilityReport{AllAdvertise, Peers}` — binary go/no-go signal
+ per-peer detail for operator triage.
- `HTFIFOCapabilityPeerStatus{Address, HasHTFIFO, Capabilities, Error}`
— one peer's polling result.
- `PollSQSHTFIFOCapability(ctx, client, peers)` — concurrent
goroutine-per-peer poll, indexed-channel result aggregation (race-free).
- Per-peer timeout `defaultSQSCapabilityPollTimeout = 3s` so a single
hung peer can't stall the cluster-wide poll.
- Body capped at 1 KiB via `io.LimitReader` so a misconfigured peer
can't drain memory.
- Bare `host:port` and full `http://…` / `https://…` URLs both accepted.
- Fail-closed on every failure mode: timeout, transport error, non-200,
malformed JSON, missing capability. Empty peer list → vacuously
`AllAdvertise=true` (caller validates list completeness).
## What's NOT added (deferred)
- `htfifoCapabilityAdvertised` stays `false`. PR 4-B-3b adds the §8
leadership-refusal hook + per-acquisition observer in
`kv/raftengine/etcd` and flips the flag.
- `CreateQueue` does NOT yet call this helper. PR 5 lifts the
`PartitionCount > 1` dormancy gate AND wires the capability check in the
same commit (per the §11 rollout plan's "gate-and-lift atomically"
rule).
## Test plan
9 top-level tests covering the contract surface:
- [x] `TestPollSQSHTFIFOCapability_AllAdvertise` — happy path, multiple
peers.
- [x] `TestPollSQSHTFIFOCapability_OneMissingFailsClosed` — old-binary
peer with empty capabilities drops `AllAdvertise`.
- [x] `TestPollSQSHTFIFOCapability_HTTPErrorFailsClosed` — HTTP 500,
connection refused, malformed JSON all surface as `Error`.
- [x] `TestPollSQSHTFIFOCapability_TimeoutFailsClosed` — hung peer
respects per-peer timeout, full poll bounded.
- [x] `TestPollSQSHTFIFOCapability_EmptyPeersIsVacuouslyTrue` — empty
peer list contract.
- [x] `TestPollSQSHTFIFOCapability_EmptyPeerAddressFailsClosed` — `""`
entry in peers slice surfaces explicit Error.
- [x] `TestPollSQSHTFIFOCapability_FullURLPeer` — `http://` and
`https://` URLs accepted alongside bare `host:port`.
- [x] `TestPollSQSHTFIFOCapability_ConcurrentPolling` — 5×200ms peers
finish in well under 1s.
- [x] `TestPollSQSHTFIFOCapability_RespectsBodyLimit` — 10 KiB response
truncated mid-string surfaces as JSON parse error, not garbage decode.
- [x] `TestBuildSQSHealthURL` — URL construction edge cases.
- [x] `go test -race ./adapter/...` pass.
- [x] `golangci-lint ./adapter/...` clean.
## Self-review (per CLAUDE.md)
1. **Data loss** — read-only HTTP poll; no FSM/Pebble/retention path. No
issue.
2. **Concurrency / distributed failures** — peer polls run in
independent goroutines; results land via an indexed channel so slice
writes are obviously race-free. Per-peer timeout enforced via
`context.WithTimeout` so a slow peer can't stall the rest. Body capped
via `io.LimitReader`. No issue.
3. **Performance** — N peers polled concurrently, not serially; the test
pins this. Per-peer cost is one HTTP round-trip + a JSON parse of a tiny
body. No hot-path impact (CreateQueue is a control-plane operation, not
request hot path). No issue.
4. **Data consistency** — fail-closed on every failure mode preserves
the §8.5 "any peer that doesn't respond is treated as not-yet-upgraded"
rule. The vacuously-true empty-peer-list case is documented and the
caller's responsibility. No issue.
5. **Test coverage** — every documented failure path (HTTP error,
transport error, JSON parse, timeout, missing capability, empty peer,
body-size cap) is pinned. Concurrent polling is pinned (would have
caught a regression to serial). URL construction edges pinned.2 files changed
Lines changed: 590 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 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 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
0 commit comments