Skip to content

Commit

Permalink
removed location for more sensible default behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
istvan-fodor committed Apr 23, 2024
1 parent af224f1 commit 1065cee
Showing 1 changed file with 8 additions and 22 deletions.
30 changes: 8 additions & 22 deletions arrow-flight/examples/flight_sql_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,7 @@ static INSTANCE_XBDC_DATA: Lazy<XdbcTypeInfoData> = Lazy::new(|| {
static TABLES: Lazy<Vec<&'static str>> = Lazy::new(|| vec!["flight_sql.example.table"]);

#[derive(Clone)]
pub struct FlightSqlServiceImpl {
location: String,
}
pub struct FlightSqlServiceImpl {}

impl FlightSqlServiceImpl {
fn check_token<T>(&self, req: &Request<T>) -> Result<(), Status> {
Expand Down Expand Up @@ -252,17 +250,15 @@ impl FlightSqlService for FlightSqlServiceImpl {
let schema = (*batch.schema()).clone();
let num_rows = batch.num_rows();
let num_bytes = batch.get_array_memory_size();
let loc = Location {
uri: self.location.clone(),
};

let fetch = FetchResults {
handle: handle.to_string(),
};
let buf = fetch.as_any().encode_to_vec().into();
let ticket = Ticket { ticket: buf };
let endpoint = FlightEndpoint {
ticket: Some(ticket),
location: vec![loc],
location: vec![],
expiration_time: None,
app_metadata: vec![].into(),
};
Expand Down Expand Up @@ -746,9 +742,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let key = std::fs::read_to_string("arrow-flight/examples/data/server.key")?;
let client_ca = std::fs::read_to_string("arrow-flight/examples/data/client_ca.pem")?;

let svc = FlightServiceServer::new(FlightSqlServiceImpl {
location: format!("grpc+tls://{}", addr_str),
});
let svc = FlightServiceServer::new(FlightSqlServiceImpl {});
let tls_config = ServerTlsConfig::new()
.identity(Identity::from_pem(&cert, &key))
.client_ca_root(Certificate::from_pem(&client_ca));
Expand All @@ -759,9 +753,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.serve(addr)
.await?;
} else {
let svc = FlightServiceServer::new(FlightSqlServiceImpl {
location: format!("grpc+tcp://{}", addr_str),
});
let svc = FlightServiceServer::new(FlightSqlServiceImpl {});

Server::builder().add_service(svc).serve(addr).await?;
}
Expand Down Expand Up @@ -845,9 +837,7 @@ mod tests {
let uds = UnixListener::bind(path.clone()).unwrap();
let stream = UnixListenerStream::new(uds);

let service = FlightSqlServiceImpl {
location: format!("grpc+unix://{}", path.clone()),
};
let service = FlightSqlServiceImpl {};
let serve_future = Server::builder()
.add_service(FlightServiceServer::new(service))
.serve_with_incoming(stream);
Expand Down Expand Up @@ -877,9 +867,7 @@ mod tests {
let (incoming, addr) = bind_tcp().await;
let uri = format!("http://{}:{}", addr.ip(), addr.port());

let service = FlightSqlServiceImpl {
location: format!("grpc+tcp://{}:{}", addr.ip(), addr.port()),
};
let service = FlightSqlServiceImpl {};
let serve_future = Server::builder()
.add_service(FlightServiceServer::new(service))
.serve_with_incoming(incoming);
Expand Down Expand Up @@ -913,9 +901,7 @@ mod tests {
let (incoming, addr) = bind_tcp().await;
let uri = format!("https://{}:{}", addr.ip(), addr.port());

let svc = FlightServiceServer::new(FlightSqlServiceImpl {
location: format!("grc+tls://{}:{}", addr.ip(), addr.port()),
});
let svc = FlightServiceServer::new(FlightSqlServiceImpl {});

let serve_future = Server::builder()
.tls_config(tls_config)
Expand Down

0 comments on commit 1065cee

Please sign in to comment.