Skip to content

Commit

Permalink
feat: Make thrift transport configurable (#194)
Browse files Browse the repository at this point in the history
* feat: make transport configurable (#188)

* implement default for HmsThriftTransport
  • Loading branch information
DeaconDesperado committed Feb 20, 2024
1 parent 027f271 commit b6bbd1d
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions crates/catalog/hms/src/catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,22 @@ use std::fmt::{Debug, Formatter};
use std::net::ToSocketAddrs;
use typed_builder::TypedBuilder;

/// Which variant of the thrift transport to communicate with HMS
/// See: <https://github.com/apache/thrift/blob/master/doc/specs/thrift-rpc.md#framed-vs-unframed-transport>
#[derive(Debug, Default)]
pub enum HmsThriftTransport {
/// Use the framed transport
Framed,
/// Use the buffered transport (default)
#[default]
Buffered,
}

/// Hive metastore Catalog configuration.
#[derive(Debug, TypedBuilder)]
pub struct HmsCatalogConfig {
address: String,
thrift_transport: HmsThriftTransport,
}

struct HmsClient(ThriftHiveMetastoreClient);
Expand Down Expand Up @@ -67,12 +79,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,
Expand Down

0 comments on commit b6bbd1d

Please sign in to comment.