Skip to content

feat: Add FDv2 wire format and protocol handler#177

Open
beekld wants to merge 2 commits into
mainfrom
bklimt/SDK-2588/fdv2-wire-types
Open

feat: Add FDv2 wire format and protocol handler#177
beekld wants to merge 2 commits into
mainfrom
bklimt/SDK-2588/fdv2-wire-types

Conversation

@beekld

@beekld beekld commented Jun 23, 2026

Copy link
Copy Markdown

Summary

  • Introduces the fdv2 module:
    • wire-format types
    • assembled ChangeSet / Selector types
    • protocol-handler state machine that folds SSE events into change sets
  • Object bodies stay as raw serde_json::Value; typed deserialization will live in a later translator.
  • Matches the C++ SDK on permissive-parsing choices:
    • Selector keeps the deprecated version field alongside state
    • Goodbye and FDv2Error use optional fields to tolerate permissively-parsed wire data
  • Module is annotated #[allow(dead_code)] for now: types are covered by unit tests but not yet reachable from the production data path.

Note

Low Risk
New isolated code with no production integration yet; behavior is confined to unit tests until the data source adopts it.

Overview
Adds a new fdv2 module (registered in lib.rs behind #[allow(dead_code)]) so FDv2 is implemented and unit-tested but not yet hooked into streaming/polling.

wire.rs defines serde models for FDv2 SSE payloads (server-intent, put-object, delete-object, payload-transferred, error, goodbye) plus assembled ChangeSet / FDv2Change types. Flag/segment bodies stay as serde_json::Value; unknown intent codes map to IntentCode::Unknown, and Goodbye / FDv2Error use optional fields for tolerant parsing.

protocol.rs implements FDv2ProtocolHandler, a small state machine that turns those events into ProtocolResult values (noop, ChangeSet, errors, or goodbye). It distinguishes full vs partial transfers, allows further put/delete cycles after the first payload-transferred without a new intent, treats intent none as an empty changeset, clears buffered changes on server error while keeping transfer state, and fully resets on goodbye (with permissive goodbye JSON parsing).

Reviewed by Cursor Bugbot for commit b84b315. Bugbot is set up for automated code reviews on this repo. Configure here.

@beekld
beekld marked this pull request as ready for review June 25, 2026 17:59
@beekld
beekld requested a review from a team as a code owner June 25, 2026 17:59
Comment thread launchdarkly-server-sdk/src/fdv2/wire.rs
pub(super) version: u64,
pub(super) kind: String,
pub(super) key: String,
pub(super) object: serde_json::Value,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do we think about using serde's raw value? Might save some cycles if we find we need to discard part of the stream.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer keeping this as Value to be consistent with how it's written in C++ and Java. I'm open to discussing it further.

Comment thread launchdarkly-server-sdk/src/fdv2/wire.rs Outdated
Comment thread launchdarkly-server-sdk/src/fdv2/wire.rs Outdated
Comment thread launchdarkly-server-sdk/src/fdv2/wire.rs Outdated
Comment thread launchdarkly-server-sdk/src/fdv2/wire.rs Outdated
Comment thread launchdarkly-server-sdk/src/fdv2/wire.rs Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b84b315. Configure here.

Comment thread launchdarkly-server-sdk/src/fdv2/protocol.rs
Comment thread launchdarkly-server-sdk/src/fdv2/protocol.rs
@beekld
beekld requested a review from keelerm84 July 14, 2026 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants