Commit 0a5e7fd
chore: improve subscription reconnection logic (#435)
Move the topic subscription reconnection logic into a retry strategy
and eligibility strategy that can be configured by the client.
Add the subscription retry strategy to TopicConfiguration. Add new
constructors that take the retry strategy, and new ones that don't take
a logger, which is only used inside the TopicConfiguration itself.
Prevent potential race conditions that could occur when unsubscribing
from a connection while it is reconnecting by checking if the user
called unsubscribe before reconnecting, and by making the variables
used in reconnection atomic.
Call close in SubscriptionWrapper when a stream ends to stop a
subscription from leaking threads from the retry executor service. We
may want to share a thread pool between the subscriptions instead of
making a new one per subscription, so that we don't need to make a new
one each time. We could also use it to execute the callbacks, which are
currently executed in the gRPC thread pool and could cause backpressure
if they are long-running.
Add empty default implementations for the test methods in
IScsTopicConnection to clean up its use in the topic client.
Remove SendSubscribeOptions, since we already have a class that contains
the callbacks, and because it had an unused subscription object.
Get rid of CancelableClientCallStreamObserver's ClientCallStreamObserver
extension, because that class is meant for observing requests, not
responses, and we only need a simple cancel method.
Make TopicClientLocalTest's unrecoverable error 'not found', because the
previous error is now recoverable.
Unsubscribe should end with onCompleted instead of onError
---------
Co-authored-by: anitarua <anita@momentohq.com>1 parent 372aa0f commit 0a5e7fd
File tree
12 files changed
+447
-394
lines changed- momento-sdk/src
- intTest/java/momento/sdk/retry
- main/java/momento/sdk
- config
- retry
- test/java/momento/sdk
12 files changed
+447
-394
lines changedLines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
122 | | - | |
| 122 | + | |
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
| |||
Lines changed: 3 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | 12 | | |
31 | 13 | | |
32 | 14 | | |
33 | 15 | | |
34 | 16 | | |
35 | 17 | | |
36 | 18 | | |
37 | | - | |
| 19 | + | |
38 | 20 | | |
39 | 21 | | |
40 | 22 | | |
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
Lines changed: 24 additions & 52 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
7 | 5 | | |
| 6 | + | |
8 | 7 | | |
9 | 8 | | |
10 | 9 | | |
| |||
14 | 13 | | |
15 | 14 | | |
16 | 15 | | |
17 | | - | |
18 | | - | |
| 16 | + | |
19 | 17 | | |
20 | 18 | | |
21 | 19 | | |
22 | | - | |
23 | 20 | | |
24 | 21 | | |
| 22 | + | |
25 | 23 | | |
26 | 24 | | |
27 | 25 | | |
28 | 26 | | |
29 | 27 | | |
| 28 | + | |
30 | 29 | | |
31 | 30 | | |
32 | 31 | | |
| |||
60 | 59 | | |
61 | 60 | | |
62 | 61 | | |
63 | | - | |
| 62 | + | |
64 | 63 | | |
65 | 64 | | |
66 | 65 | | |
| |||
69 | 68 | | |
70 | 69 | | |
71 | 70 | | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
| 71 | + | |
90 | 72 | | |
91 | 73 | | |
92 | 74 | | |
| |||
105 | 87 | | |
106 | 88 | | |
107 | 89 | | |
108 | | - | |
| 90 | + | |
109 | 91 | | |
110 | 92 | | |
111 | | - | |
| 93 | + | |
112 | 94 | | |
113 | 95 | | |
114 | 96 | | |
| |||
133 | 115 | | |
134 | 116 | | |
135 | 117 | | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
| 118 | + | |
| 119 | + | |
145 | 120 | | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
158 | 124 | | |
159 | 125 | | |
160 | 126 | | |
| |||
166 | 132 | | |
167 | 133 | | |
168 | 134 | | |
169 | | - | |
| 135 | + | |
| 136 | + | |
170 | 137 | | |
171 | | - | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
172 | 145 | | |
173 | 146 | | |
174 | 147 | | |
175 | 148 | | |
176 | 149 | | |
177 | 150 | | |
178 | | - | |
179 | | - | |
180 | | - | |
| 151 | + | |
| 152 | + | |
181 | 153 | | |
182 | 154 | | |
183 | 155 | | |
| |||
Lines changed: 0 additions & 151 deletions
This file was deleted.
0 commit comments