Commit 502967c
authored
Use data-bearing enum variants pattern in negotiation (#1727)
During negotiation, there are certain pieces of data which are only
relevant in particular states:
- Before connecting, the client has a `oneshot::Sender<()>` which kicks
off the connection when triggered
- When waiting for a quorum, each client stores a `RegionMetadata`, to
be used when computing reconciliation
Previously, these two pieces of data were always present in the
`DownstairsClient` object, and were checked (or unwrapped) at the
relevant points in negotiation.
This PR moves them into the relevant `NegotiationState` variants, so
they are _guaranteed_ to be present at the right times.
Unfortunately, `NegotiationState` is also used (as a member of
`DsState`) in serialization, for both OpenAPI calls and DTrace probes.
We can't serialize or log a oneshot sender (or region metadata), which
is a problem!
The **vast majority** of this PR is separating the
serialization-friendly subset of data (`DsState` and `NegotiationState`)
from the data-bearing variants (new `DsStateData` and
`NegotiationStateData`).
There's also one subtlety: the PR adds a new
`NegotiationState::WaitConnect(oneshot::Sender<()>)`. Previously,
`NegotiationState::Start` represented both "waiting for connection
oneshot to fire" and "waiting for connection to the Downstairs"
(depending on whether `ClientTaskHandle::client_connect_tx` was present
or not). This change makes those two sub-states distinct.1 parent 957349a commit 502967c
File tree
11 files changed
+448
-347
lines changed- cmon/src
- openapi
- upstairs
- src
11 files changed
+448
-347
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | | - | |
| 102 | + | |
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
89 | | - | |
| 89 | + | |
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
280 | 280 | | |
281 | 281 | | |
282 | 282 | | |
283 | | - | |
| 283 | + | |
284 | 284 | | |
285 | 285 | | |
286 | 286 | | |
| |||
384 | 384 | | |
385 | 385 | | |
386 | 386 | | |
387 | | - | |
| 387 | + | |
388 | 388 | | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
389 | 404 | | |
390 | 405 | | |
391 | 406 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
47 | 46 | | |
48 | 47 | | |
49 | 48 | | |
50 | | - | |
51 | | - | |
| 49 | + | |
| 50 | + | |
52 | 51 | | |
| 52 | + | |
| 53 | + | |
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
| |||
0 commit comments