Skip to content

Commit

Permalink
feat: make transport configurable (apache#188)
Browse files Browse the repository at this point in the history
  • Loading branch information
DeaconDesperado committed Feb 9, 2024
1 parent 645f9dd commit 32ad005
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions crates/catalog/hms/src/catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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: https://github.com/apache/thrift/blob/master/doc/specs/thrift-rpc.md#framed-vs-unframed-transport
#[derive(Debug)]
pub enum HmsTransport {
/// 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: HmsTransport,
}

struct HmsClient(ThriftHiveMetastoreClient);
Expand Down Expand Up @@ -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 {
HmsTransport::Framed => builder
.make_codec(volo_thrift::codec::default::DefaultMakeCodec::framed())
.build(),
HmsTransport::Buffered => builder
.make_codec(volo_thrift::codec::default::DefaultMakeCodec::buffered())
.build(),
};

Ok(Self {
config,
Expand Down

0 comments on commit 32ad005

Please sign in to comment.