Commit c3fe7d2
authored
Durability: ack-after-delivery + drain on shutdown, proven by an e2e suite (#16)
* Ack after delivery and drain on shutdown (#1)
Close the durability gap: rtbeat previously returned HTTP 200 before the
event was delivered and closed the publisher without draining, so an
upstream sender that treats the 200 as durable (e.g. rxtx removing a
batch from its on-disk queue) could lose in-flight events on a restart.
Delivery:
- POST /in now publishes the batch with GuaranteedSend and waits for the
output to acknowledge it before responding. Per-batch correlation uses
a batchAck token carried in each event's Private field, surfaced via
acker.EventPrivateReporter. On ack -> 200; on timeout -> 504 so the
sender keeps its durable copy and retries (pair with a deterministic
doc id downstream to dedupe). The ack budget is the previously-unused
config "timeout" (default 5s).
Shutdown:
- ClientConfig gains WaitClose; Stop signals and Run drains in the right
order: stop HTTP intake -> let in-flight handlers finish -> close the
client (drains outstanding events up to the new "shutdown_timeout",
default 30s). Closing before intake stops would let a late batch
publish into a closing pipeline and be lost.
Also:
- Remove the stray leading zero-value event published with every batch.
- Clamp non-positive timeout / shutdown_timeout to defaults (a zero ack
timeout would 504 everything; a zero shutdown timeout would silently
disable the drain).
- Tests cover delivered/timeout/empty/bad-JSON handler paths, partial
and multi-batch ack resolution, the lifecycle, and config clamping
(beater 92%); config example, docs, and CHANGELOG updated.
Closes #1
* Add end-to-end durability tests (#1)
Prove the #1 durability guarantees against real components instead of
fakes: a black-box suite (build tag e2e) builds and runs the actual
rtbeat binary shipping to a real libbeat logstash output backed by a
controllable go-lumber lumberjack server.
Tests:
- AckAfterDelivery: 200 only after a real over-the-wire ack.
- WaitsForAckBeforeOK: delayed ack proves the 200 waits for delivery
(asserts elapsed >= ack delay), not acked on receipt.
- StallReturns504: a stalled output yields 504, and the event still
reached the output (so the sender retries rather than dropping it).
- MultiMessageFragmentedAck: with bulk_max_size=1 a single /in batch is
acked in fragments across multiple callbacks over the wire, exercising
the per-batch ack correlation.
- DrainsInFlightOnShutdown: an in-flight request is delivered on SIGTERM
(graceful drain) and the process exits cleanly.
Out of scope (documented in the package doc): hard-crash and
cross-restart durability, which rely on sender retry-on-non-2xx and an
optional libbeat disk queue.
Also: a dedicated e2e CI job, a `make e2e` target, and go-lumber
promoted to a direct dependency. The suite is tag-gated, so the default
`go test` / `make verify` stay fast and offline.
* Replace CHANGELOG contents with a pointer to GitHub Releases
Stop hand-maintaining a Keep-a-Changelog file; GoReleaser already
generates per-release notes on GitHub Releases. CHANGELOG.md now just
points there.1 parent 1cef2bf commit c3fe7d2
12 files changed
Lines changed: 812 additions & 108 deletions
File tree
- .github/workflows
- beater
- config
- docs
- test/e2e
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
77 | 96 | | |
78 | 97 | | |
79 | 98 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
| 3 | + | |
5 | 4 | | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
| 5 | + | |
| 6 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
63 | 71 | | |
64 | 72 | | |
65 | 73 | | |
| |||
87 | 95 | | |
88 | 96 | | |
89 | 97 | | |
| 98 | + | |
90 | 99 | | |
91 | 100 | | |
92 | 101 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
10 | 12 | | |
11 | 13 | | |
12 | 14 | | |
| |||
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
48 | 60 | | |
49 | 61 | | |
50 | 62 | | |
| |||
98 | 110 | | |
99 | 111 | | |
100 | 112 | | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
111 | 137 | | |
112 | 138 | | |
113 | 139 | | |
| |||
123 | 149 | | |
124 | 150 | | |
125 | 151 | | |
126 | | - | |
| 152 | + | |
| 153 | + | |
127 | 154 | | |
128 | 155 | | |
129 | 156 | | |
| |||
164 | 191 | | |
165 | 192 | | |
166 | 193 | | |
167 | | - | |
168 | | - | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
169 | 202 | | |
170 | 203 | | |
| 204 | + | |
171 | 205 | | |
172 | 206 | | |
173 | 207 | | |
174 | | - | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
175 | 211 | | |
176 | | - | |
| 212 | + | |
177 | 213 | | |
178 | 214 | | |
179 | 215 | | |
| |||
183 | 219 | | |
184 | 220 | | |
185 | 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 | + | |
| 259 | + | |
186 | 260 | | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
194 | 267 | | |
195 | 268 | | |
196 | 269 | | |
197 | 270 | | |
198 | 271 | | |
199 | 272 | | |
200 | 273 | | |
201 | | - | |
| 274 | + | |
202 | 275 | | |
203 | 276 | | |
204 | 277 | | |
205 | 278 | | |
206 | 279 | | |
207 | 280 | | |
208 | 281 | | |
209 | | - | |
210 | | - | |
211 | | - | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
212 | 289 | | |
213 | 290 | | |
214 | 291 | | |
| |||
224 | 301 | | |
225 | 302 | | |
226 | 303 | | |
227 | | - | |
228 | | - | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
229 | 312 | | |
230 | | - | |
231 | 313 | | |
232 | 314 | | |
233 | | - | |
| 315 | + | |
| 316 | + | |
234 | 317 | | |
235 | 318 | | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
236 | 334 | | |
237 | 335 | | |
0 commit comments