Commit d182f7e
authored
chore: Add FDv2 Protocol Handling (#184)
This implements a protocol handling state machine for FDv2. The state
machine handles each event type for a connection and returns an action
the caller should take.
The expectation is that streaming/polling create a new protocol handler
per connection. As events are received they are pushed into the the
protocol handler. For each event the protocol handler will return an
action to take. An action could be emitting a changeset, preparing for a
disconnect, or logging an informative message.
Currently the protocol handler doesn't directly include any event or
logging capability and delegates all responsibility to the caller.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Adds an FDv2 protocol state machine that processes events and emits
changesets, replaces the polling event wrapper with a unified event
type, introduces intent code handling, and changes PutObject to store
raw JSON strings with comprehensive tests.
>
> - **FDv2 Protocol/State Machine**:
> - Add `FDv2ProtocolHandler` with actions (`Changeset`, `Error`,
`Goodbye`, `None`, `InternalError`) and error types; handles
`server-intent`, `put-object`, `delete-object`, `payload-transferred`,
`goodbye`, `heartbeat` and emits `FDv2ChangeSet`.
> - New data models: `FDv2Change`, `FDv2ChangeSet` (Full/Partial/None),
`FDv2Selector`, and `FDv2EventTypes`.
> - **Event/Payload Model**:
> - Replace `FDv2PollEvent` with unified `FDv2Event` (type + raw JSON)
and `FDv2PollEventConverter`.
> - Add `IntentCode` enum + converter; update
`ServerIntent`/`ServerIntentPayload` to use it.
> - Change `PutObject.Object` from `JsonElement` to raw JSON `string`;
update read/write to preserve raw payload.
> - **Tests**:
> - Add `Internal/FDv2DataSources/FDv2ProtocolHandlerTest` covering
state transitions, errors, resets, and changeset emission.
> - Update `Internal/FDv2Payloads/FDv2PayloadsTest` for new event
wrapper, `IntentCode`, and `PutObject` serialization.
> - **Project**:
> - Add test folder include `Internal/FDv2DataSources/` in
`LaunchDarkly.ServerSdk.Tests.csproj`.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
9c4653b. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 10b2f4a commit d182f7e
File tree
12 files changed
+2102
-197
lines changed- pkgs/sdk/server
- src/Internal
- FDv2DataSources
- FDv2Payloads
- test
- Internal
- FDv2DataSources
- FDv2Payloads
12 files changed
+2102
-197
lines changedLines changed: 139 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 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 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
Lines changed: 16 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
0 commit comments