Commit 3a35b6d
fix(reconnect): maxRetries(0) and configurable connectionTimeoutMs; auto-wire transport factory policy
Reworks the Layer-4 patch (#45) per @lukeocodes' review. Replaces the previous
ClientOptions.reconnect(boolean) flag and the four duplicated WebSocketClient
listeners with the underlying bug fixes in ReconnectingWebSocketListener plus
a clean policy-declaration hook on DeepgramTransportFactory.
Reverts (no edits to generated WS clients, no .fernignore freeze inflation):
- ClientOptions.reconnect(boolean) field/getter/builder method.
- if (transportFactory != null) builder.reconnect(false) auto-disable
heuristic in both DeepgramClientBuilder and AsyncDeepgramClientBuilder.
- The four resources/.../websocket/*WebSocketClient.java listener
duplications and their .fernignore freeze entries.
Bug fixes in ReconnectingWebSocketListener (now temporarily frozen):
- maxRetries(0) used to refuse to connect because the gate compared
retryCount.get() >= maxRetries on the initial attempt (retryCount starts
at 0). The initial attempt is not a retry; the gate is now > maxRetries
so the count caps retries only. maxRetries(0) means "1 attempt, no
retries" as the API name implies.
- The 4000 ms connectionFuture.get(...) timeout is now configurable via a
new connectionTimeoutMs field on ReconnectOptions (default 4000,
validated > 0). The hardcoded literal is gone.
- Adds applyOptionsOverride(ReconnectOptions) so a transport-factory wrapper
can rewire policy on the listener after construction. Used by
TransportWebSocketFactory to honour the new factory hook below without
requiring edits to the per-resource WebSocketClient classes.
Plugin policy declaration:
- DeepgramTransportFactory (already permanently frozen) gains a default
ReconnectOptions reconnectOptions() method returning null. Plugins
managing their own connection lifecycle (e.g. SageMaker) override this
to return ReconnectOptions.builder().maxRetries(0).build() so the
SDK's wrapper-level reconnect doesn't compound their internal retries
into a Throttling-on-Throttling storm under burst load.
- TransportWebSocketFactory.create() applies factory.reconnectOptions()
to the wrapping ReconnectingWebSocketListener via the new override hook.
Auto-wiring with no edits to generated code.
Tests:
- New ReconnectingWebSocketListenerTest covers the maxRetries(0)
regression, connectionTimeoutMs default + customisation + validation,
and applyOptionsOverride no-op + retry-gate behaviour.
Net diff vs the prior PR head: 4 files changed (+94/−10) instead of 8 files
(+364/−24). Freeze list grows by 1 (the listener), shrinks by 4 (the WS
clients).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 6cfd64d commit 3a35b6d
12 files changed
Lines changed: 307 additions & 373 deletions
File tree
- src
- main/java/com/deepgram
- core
- transport
- resources
- agent/v1/websocket
- listen
- v1/websocket
- v2/websocket
- speak/v1/websocket
- test/java/com/deepgram/core
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
32 | 26 | | |
33 | 27 | | |
34 | 28 | | |
| |||
Lines changed: 0 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | 121 | | |
127 | 122 | | |
128 | 123 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | 120 | | |
126 | 121 | | |
127 | 122 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
31 | | - | |
32 | 30 | | |
33 | 31 | | |
34 | 32 | | |
| |||
37 | 35 | | |
38 | 36 | | |
39 | 37 | | |
40 | | - | |
41 | | - | |
| 38 | + | |
42 | 39 | | |
43 | 40 | | |
44 | 41 | | |
| |||
56 | 53 | | |
57 | 54 | | |
58 | 55 | | |
59 | | - | |
60 | 56 | | |
61 | 57 | | |
62 | 58 | | |
| |||
110 | 106 | | |
111 | 107 | | |
112 | 108 | | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | 109 | | |
126 | 110 | | |
127 | 111 | | |
| |||
143 | 127 | | |
144 | 128 | | |
145 | 129 | | |
146 | | - | |
147 | | - | |
148 | 130 | | |
149 | 131 | | |
150 | 132 | | |
| |||
205 | 187 | | |
206 | 188 | | |
207 | 189 | | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | 190 | | |
220 | 191 | | |
221 | 192 | | |
| |||
249 | 220 | | |
250 | 221 | | |
251 | 222 | | |
252 | | - | |
253 | | - | |
| 223 | + | |
254 | 224 | | |
255 | 225 | | |
256 | 226 | | |
| |||
265 | 235 | | |
266 | 236 | | |
267 | 237 | | |
268 | | - | |
269 | 238 | | |
270 | 239 | | |
271 | 240 | | |
| |||
Lines changed: 65 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
29 | 32 | | |
30 | | - | |
| 33 | + | |
31 | 34 | | |
32 | | - | |
| 35 | + | |
33 | 36 | | |
34 | | - | |
| 37 | + | |
35 | 38 | | |
36 | 39 | | |
37 | 40 | | |
| 41 | + | |
| 42 | + | |
38 | 43 | | |
39 | 44 | | |
40 | 45 | | |
| |||
66 | 71 | | |
67 | 72 | | |
68 | 73 | | |
| 74 | + | |
69 | 75 | | |
70 | 76 | | |
71 | 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 | + | |
72 | 104 | | |
73 | 105 | | |
74 | 106 | | |
75 | 107 | | |
76 | | - | |
| 108 | + | |
77 | 109 | | |
78 | | - | |
| 110 | + | |
| 111 | + | |
79 | 112 | | |
80 | 113 | | |
81 | 114 | | |
| |||
86 | 119 | | |
87 | 120 | | |
88 | 121 | | |
89 | | - | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
90 | 126 | | |
91 | 127 | | |
92 | 128 | | |
93 | 129 | | |
94 | 130 | | |
95 | 131 | | |
96 | | - | |
| 132 | + | |
97 | 133 | | |
98 | 134 | | |
99 | 135 | | |
100 | | - | |
| 136 | + | |
101 | 137 | | |
102 | 138 | | |
103 | 139 | | |
| |||
399 | 435 | | |
400 | 436 | | |
401 | 437 | | |
| 438 | + | |
| 439 | + | |
402 | 440 | | |
403 | 441 | | |
404 | 442 | | |
405 | 443 | | |
406 | 444 | | |
407 | 445 | | |
| 446 | + | |
408 | 447 | | |
409 | 448 | | |
410 | 449 | | |
| |||
422 | 461 | | |
423 | 462 | | |
424 | 463 | | |
| 464 | + | |
| 465 | + | |
425 | 466 | | |
426 | 467 | | |
427 | 468 | | |
428 | 469 | | |
429 | 470 | | |
430 | 471 | | |
| 472 | + | |
431 | 473 | | |
432 | 474 | | |
433 | 475 | | |
| |||
455 | 497 | | |
456 | 498 | | |
457 | 499 | | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
458 | 510 | | |
459 | 511 | | |
460 | 512 | | |
| |||
463 | 515 | | |
464 | 516 | | |
465 | 517 | | |
| 518 | + | |
466 | 519 | | |
467 | 520 | | |
468 | 521 | | |
| |||
487 | 540 | | |
488 | 541 | | |
489 | 542 | | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
490 | 546 | | |
491 | 547 | | |
492 | 548 | | |
| |||
Lines changed: 16 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
22 | | - | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
34 | 49 | | |
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
34 | 42 | | |
35 | 43 | | |
36 | 44 | | |
| |||
0 commit comments