avantgardnerio commented on code in PR #3207:
URL: https://github.com/apache/arrow-rs/pull/3207#discussion_r1042676364
##########
arrow-flight/examples/flight_sql_server.rs:
##########
@@ -360,3 +461,85 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
Ok(())
}
+
+#[derive(Clone, PartialEq, ::prost::Message)]
+pub struct FetchResults {
+ #[prost(string, tag = "1")]
+ pub handle: ::prost::alloc::string::String,
+}
+
+impl ProstMessageExt for FetchResults {
+ fn type_url() -> &'static str {
+ "type.googleapis.com/arrow.flight.protocol.sql.FetchResults"
+ }
+
+ fn as_any(&self) -> Any {
+ prost_types::Any {
+ type_url: FetchResults::type_url().to_string(),
+ value: ::prost::Message::encode_to_vec(self),
+ }
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use futures::TryStreamExt;
+
+ use arrow::util::pretty::pretty_format_batches;
+ use arrow_flight::utils::flight_data_to_batches;
+ use tower::service_fn;
+
+ async fn client_with_uds(path: String) -> FlightSqlServiceClient {
+ let connector = service_fn(move |_| UnixStream::connect(path.clone()));
+ let channel = Endpoint::try_from("https://example.com")
+ .unwrap()
+ .connect_with_connector(connector)
+ .await
+ .unwrap();
+ FlightSqlServiceClient::new(channel)
+ }
+
+ #[tokio::test]
+ async fn test_select_1() {
+ let file = NamedTempFile::new().unwrap();
+ let path = file.into_temp_path().to_str().unwrap().to_string();
+ let _ = fs::remove_file(path.clone());
+
+ let uds = UnixListener::bind(path.clone()).unwrap();
+ let stream = UnixListenerStream::new(uds);
+
+ // We would just listen on TCP, but it seems impossible to know when
tonic is ready to serve
Review Comment:
I wish they would add a method where you can await actual start, or a
oneshot channel, or something, but I guess this is where we are.
I also like this approach because it allows the tests to run in parallel.
I'm open to either way, I don't have a strong opinion here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]