feat(internode): define transport capabilities (#3047)

Co-authored-by: Henry Guo <marshawcoco@users.noreply.github.com>
Co-authored-by: houseme <housemecn@gmail.com>
This commit is contained in:
Henry Guo
2026-05-22 10:56:37 +08:00
committed by GitHub
parent 3e3fcbf44d
commit b42766f1d3
2 changed files with 100 additions and 18 deletions
@@ -41,23 +41,35 @@ fn unsupported_transport_message(transport: &str) -> String {
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub struct InternodeDataTransportCapabilities {
pub stream_read: bool,
pub stream_write: bool,
pub walk_dir: bool,
pub registered_memory: bool,
pub scatter_gather: bool,
pub zero_copy_receive: bool,
/// Backend can open a streaming remote disk reader.
pub streaming_read: bool,
/// Backend can open a streaming remote disk writer.
pub streaming_write: bool,
/// Backend can stream walk-dir responses.
pub streaming_walk_dir: bool,
/// Backend has an API shape that could avoid an extra user-space copy.
pub zero_copy_candidate: bool,
/// Backend cannot transfer payloads unless buffers are registered or pinned.
pub registered_memory_required: bool,
/// Backend preserves in-order delivery for each opened transfer.
pub ordered_delivery: bool,
/// Largest payload the backend accepts for one transfer, or no RustFS-level cap.
pub max_transfer_size: Option<usize>,
/// Backend can participate in the behavior-preserving TCP fallback path.
pub fallback_supported: bool,
}
impl InternodeDataTransportCapabilities {
pub const fn tcp_http() -> Self {
Self {
stream_read: true,
stream_write: true,
walk_dir: true,
registered_memory: false,
scatter_gather: false,
zero_copy_receive: false,
streaming_read: true,
streaming_write: true,
streaming_walk_dir: true,
zero_copy_candidate: false,
registered_memory_required: false,
ordered_delivery: true,
max_transfer_size: None,
fallback_supported: true,
}
}
}
@@ -223,16 +235,29 @@ mod tests {
assert_eq!(
transport.capabilities(),
InternodeDataTransportCapabilities {
stream_read: true,
stream_write: true,
walk_dir: true,
registered_memory: false,
scatter_gather: false,
zero_copy_receive: false,
streaming_read: true,
streaming_write: true,
streaming_walk_dir: true,
zero_copy_candidate: false,
registered_memory_required: false,
ordered_delivery: true,
max_transfer_size: None,
fallback_supported: true,
}
);
}
#[test]
fn tcp_http_capabilities_do_not_advertise_rdma_specific_features() {
let capabilities = TcpHttpInternodeDataTransport.capabilities();
assert!(!capabilities.zero_copy_candidate);
assert!(!capabilities.registered_memory_required);
assert!(capabilities.ordered_delivery);
assert_eq!(capabilities.max_transfer_size, None);
assert!(capabilities.fallback_supported);
}
#[test]
fn read_file_stream_url_encodes_query_values() {
let url = build_read_file_stream_url(&ReadStreamRequest {