From 15c212d6eee756a82fe92ebbde68456122916c97 Mon Sep 17 00:00:00 2001 From: Mark Grey Date: Fri, 9 Feb 2024 17:33:00 -0500 Subject: [PATCH 1/2] feat: make transport configurable (#188) --- crates/catalog/hms/src/catalog.rs | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/crates/catalog/hms/src/catalog.rs b/crates/catalog/hms/src/catalog.rs index f3eab62ea..054d500b5 100644 --- a/crates/catalog/hms/src/catalog.rs +++ b/crates/catalog/hms/src/catalog.rs @@ -29,10 +29,21 @@ use std::fmt::{Debug, Formatter}; use std::net::ToSocketAddrs; use typed_builder::TypedBuilder; +/// Which variant of the thrift transport to communicate with HMS +/// See: +#[derive(Debug)] +pub enum HmsThriftTransport { + /// Use the framed transport + Framed, + /// Use the buffered transport (default) + Buffered, +} + /// Hive metastore Catalog configuration. #[derive(Debug, TypedBuilder)] pub struct HmsCatalogConfig { address: String, + thrift_transport: HmsThriftTransport, } struct HmsClient(ThriftHiveMetastoreClient); @@ -67,12 +78,16 @@ impl HmsCatalog { ) })?; - let client = ThriftHiveMetastoreClientBuilder::new("hms") - .address(address) - // Framed thrift rpc is not enabled by default in HMS, we use - // buffered instead. - .make_codec(volo_thrift::codec::default::DefaultMakeCodec::buffered()) - .build(); + let builder = ThriftHiveMetastoreClientBuilder::new("hms").address(address); + + let client = match &config.thrift_transport { + HmsThriftTransport::Framed => builder + .make_codec(volo_thrift::codec::default::DefaultMakeCodec::framed()) + .build(), + HmsThriftTransport::Buffered => builder + .make_codec(volo_thrift::codec::default::DefaultMakeCodec::buffered()) + .build(), + }; Ok(Self { config, From aa7ca58929afb900286f5ce841f6d74004f26159 Mon Sep 17 00:00:00 2001 From: Mark Grey Date: Sat, 17 Feb 2024 09:59:02 -0500 Subject: [PATCH 2/2] implement default for HmsThriftTransport --- crates/catalog/hms/src/catalog.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/catalog/hms/src/catalog.rs b/crates/catalog/hms/src/catalog.rs index 054d500b5..a00aaf337 100644 --- a/crates/catalog/hms/src/catalog.rs +++ b/crates/catalog/hms/src/catalog.rs @@ -31,11 +31,12 @@ use typed_builder::TypedBuilder; /// Which variant of the thrift transport to communicate with HMS /// See: -#[derive(Debug)] +#[derive(Debug, Default)] pub enum HmsThriftTransport { /// Use the framed transport Framed, /// Use the buffered transport (default) + #[default] Buffered, }