Commit b20c35e
authored
fix: Close the final initializer on exhaustion; document the source manager contract (#304)
## What this changes
Two small behavior hardenings and an explicit statement of the source
manager's API contract.
- **Initializer exhaustion closes the final initializer.** Every other
transition closes the previous source when the next one is activated,
but the exhaustion path returned null with the last initializer still
active. When no synchronizer activation follows, that initializer (and
its HTTP client) was held until shutdown. A terminal null now leaves no
source running.
- **`engageFdv1Fallback()` is a no-op when no FDv1 fallback slot is
configured.** Blocking every slot without unblocking a fallback would
leave nothing to activate. The orchestration layer checks before
engaging; the guard makes the operation safe regardless of the caller.
- **`hasFdv1FallbackConfigured`** replaces `hasFdv1Fallback` to make
clear it reports configuration, not engagement state.
## The documented contract
The class docs now state the assumptions the manager operates under, so
they are visible at the API surface rather than implicit in the call
sites:
- The manager assumes a single, sequential driver. At most one source is
active at a time: activating a source closes the previous one,
exhaustion closes the final initializer, and `close` closes whatever
remains.
- The synchronizer scan cursor doubles as the active-slot pointer. From
an activation (`nextAvailableSynchronizer` /
`recreateCurrentSynchronizer`) until the next cursor mutation
(`resetSynchronizerIndex` / `engageFdv1Fallback`), the cursor identifies
the running synchronizer's slot — `isPrimarySynchronizer` and
`blockCurrentSynchronizer` read it and are only meaningful inside that
window. After mutating the cursor, a new synchronizer must be activated
before consulting either. The driver satisfies this by construction:
both reads happen strictly between an activation and the run's outcome
being decided, and cursor mutations happen only after the outcome is
decided.
## Testing
New tests pin the exhaustion close (a terminal null leaves no source
running) and the fallback-engagement guard (engaging with no configured
FDv1 slot leaves the slot list untouched). Full package suite passes.
SDK-21861 parent 761ed9d commit b20c35e
2 files changed
Lines changed: 74 additions & 10 deletions
File tree
- packages/common_client
- lib/src/data_sources/fdv2
- test/data_sources/fdv2
Lines changed: 43 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
36 | 51 | | |
37 | 52 | | |
38 | 53 | | |
| |||
66 | 81 | | |
67 | 82 | | |
68 | 83 | | |
69 | | - | |
| 84 | + | |
| 85 | + | |
70 | 86 | | |
71 | 87 | | |
72 | 88 | | |
73 | 89 | | |
74 | 90 | | |
| 91 | + | |
75 | 92 | | |
76 | 93 | | |
77 | 94 | | |
| |||
130 | 147 | | |
131 | 148 | | |
132 | 149 | | |
133 | | - | |
134 | | - | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
135 | 154 | | |
136 | 155 | | |
137 | 156 | | |
| |||
140 | 159 | | |
141 | 160 | | |
142 | 161 | | |
143 | | - | |
144 | | - | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
145 | 167 | | |
146 | 168 | | |
147 | 169 | | |
148 | 170 | | |
149 | | - | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
150 | 177 | | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
151 | 181 | | |
152 | 182 | | |
153 | 183 | | |
| |||
156 | 186 | | |
157 | 187 | | |
158 | 188 | | |
159 | | - | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
160 | 193 | | |
161 | 194 | | |
162 | 195 | | |
| |||
165 | 198 | | |
166 | 199 | | |
167 | 200 | | |
168 | | - | |
169 | | - | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
170 | 204 | | |
171 | 205 | | |
172 | 206 | | |
| |||
Lines changed: 31 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
79 | 96 | | |
80 | 97 | | |
81 | 98 | | |
| |||
150 | 167 | | |
151 | 168 | | |
152 | 169 | | |
153 | | - | |
| 170 | + | |
154 | 171 | | |
155 | 172 | | |
156 | 173 | | |
| |||
165 | 182 | | |
166 | 183 | | |
167 | 184 | | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
168 | 198 | | |
169 | 199 | | |
170 | 200 | | |
| |||
0 commit comments