-
Notifications
You must be signed in to change notification settings - Fork 45
[client] Allow bootstrap endpoint with unknown server type #622
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
9d2a5af
69b8eb4
0c108a6
c05b90e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -156,20 +156,21 @@ fn validate_server_type( | |
| expected: &ServerType, | ||
| response_server_type: Option<i32>, | ||
| ) -> Result<(), Error> { | ||
| if *expected == ServerType::Unknown { | ||
| return Ok(()); | ||
| } | ||
|
|
||
| // For forward-compat with servers that do not populate `server_type`, validation is skipped. | ||
| let Some(type_id) = response_server_type else { | ||
| return Ok(()); | ||
| }; | ||
| let actual = ServerType::from_type_id(type_id); | ||
| if actual.as_ref() == Some(expected) { | ||
| if &actual == expected { | ||
| return Ok(()); | ||
| } | ||
| let actual_desc = actual | ||
| .map(|t| t.to_string()) | ||
| .unwrap_or_else(|| format!("Unknown(type_id={type_id})")); | ||
| Err(Error::InvalidServerType { | ||
| message: format!( | ||
| "Expected server type {expected} but the server advertised {actual_desc}. \ | ||
| "Expected server type {expected} but the server advertised {actual}. \ | ||
| The client may be talking to the wrong endpoint \ | ||
| (e.g. coordinator vs tablet server)." | ||
| ), | ||
|
|
@@ -1268,6 +1269,21 @@ mod tests { | |
| ) | ||
| .is_ok() | ||
| ); | ||
| assert!( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should a simple integration test case be made in existing IT testing with unknown type/bootstrapping against tablet server?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added an integration test covering bootstrapping from a tablet server endpoint. The test uses the shared cluster's tablet plaintext listener as bootstrap_servers, creates a FlussConnection, and verifies server node discovery returns both coordinator and tablet nodes. |
||
| validate_server_type( | ||
| &ServerType::Unknown, | ||
| Some(ServerType::CoordinatorServer.to_type_id()), | ||
| ) | ||
| .is_ok() | ||
| ); | ||
| assert!( | ||
| validate_server_type( | ||
| &ServerType::Unknown, | ||
| Some(ServerType::TabletServer.to_type_id()), | ||
| ) | ||
| .is_ok() | ||
| ); | ||
| assert!(validate_server_type(&ServerType::Unknown, Some(99),).is_ok()); | ||
|
|
||
| // Mismatch: connected to a coordinator while expecting a tablet server | ||
| // (and vice versa). | ||
|
|
@@ -1290,8 +1306,8 @@ mod tests { | |
| )); | ||
|
|
||
| validate_server_type(&ServerType::TabletServer, None).ok(); | ||
| // Unknown / unmapped type id still fails, with the raw id surfaced so | ||
| // operators can diagnose protocol drift. | ||
| // Unknown / unmapped type id is treated as Unknown, which still fails | ||
| // when the client expects a concrete server type. | ||
| assert!(matches!( | ||
| validate_server_type(&ServerType::CoordinatorServer, Some(99),), | ||
| Err(Error::InvalidServerType { .. }) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -99,9 +99,12 @@ Complete API reference for the Fluss Rust client. | |
| | `fn id(&self) -> i32` | Server node ID | | ||
| | `fn host(&self) -> &str` | Hostname of the server | | ||
| | `fn port(&self) -> u32` | Port number | | ||
| | `fn server_type(&self) -> &ServerType` | Server type (`CoordinatorServer` or `TabletServer`) | | ||
| | `fn server_type(&self) -> &ServerType` | Server type (`CoordinatorServer`, `TabletServer`, or `Unknown`) | | ||
| | `fn uid(&self) -> &str` | Unique identifier (e.g. `"cs-0"`, `"ts-1"`) | | ||
|
|
||
| `ServerType::Unknown` is used when the client has not yet determined the endpoint | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think other bindings' api reference also have it, but maybe i am wrong |
||
| type, such as bootstrap endpoints. | ||
|
|
||
| ## `FlussTable<'a>` | ||
|
|
||
| | Method | Description | | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think we should update api-reference for this too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the Rust API reference to include
ServerType::Unknownand documented that it is used when the client has not yet determined the endpoint type, such as bootstrap endpoints.