Skip to content

Commit

Permalink
Add gRPC reflection support to arrow flight
Browse files Browse the repository at this point in the history
Addresses #1706, adding a
constant to the gRPC generated code so it is possible to include the
Flight and Flight SQL APIs in a `tonic-reflection` service.

Testing:

```
grpcurl --plaintext localhost:8082 list
```
  • Loading branch information
jacobsimpson committed Jan 22, 2025
1 parent 595a835 commit 06b64bc
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions arrow-flight/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ tracing-log = { version = "0.2" }
tracing-subscriber = { version = "0.3.1", default-features = false, features = ["ansi", "env-filter", "fmt"] }
tokio = { version = "1.0", default-features = false, features = ["macros", "rt", "rt-multi-thread"] }
tokio-stream = { version = "0.1", features = ["net"] }
tonic-reflection = "0.12.3"
tower = { version = "0.5.0", features = ["util"] }
uuid = { version = "1.10.0", features = ["v4"] }

Expand Down
2 changes: 2 additions & 0 deletions arrow-flight/gen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// protoc in Ubuntu builder needs this option
.protoc_arg("--experimental_allow_proto3_optional")
.out_dir("src")
.file_descriptor_set_path("src/flight_descriptor.bin")
.compile_protos_with_config(prost_config(), &[proto_path], &[proto_dir])?;

// read file contents to string
Expand All @@ -52,6 +53,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// protoc in Ubuntu builder needs this option
.protoc_arg("--experimental_allow_proto3_optional")
.out_dir("src/sql")
.file_descriptor_set_path("src/sql/flight_sql_descriptor.bin")
.compile_protos_with_config(prost_config(), &[proto_path], &[proto_dir])?;

// read file contents to string
Expand Down
Binary file added arrow-flight/src/flight_descriptor.bin
Binary file not shown.
13 changes: 13 additions & 0 deletions arrow-flight/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,25 @@ mod gen {
// Since this file is auto-generated, we suppress all warnings
#![allow(missing_docs)]
include!("arrow.flight.protocol.rs");

/// The descriptor used for making the Arrow Flight gRPC API available for [gRPC
/// reflection](https://grpc.io/docs/guides/reflection/).
///
/// ```
/// let reflection_server = tonic_reflection::server::Builder::configure()
/// .register_encoded_file_descriptor_set(arrow_flight::flight_descriptor::FILE_DESCRIPTOR_SET)
/// .build_v1()
/// .unwrap();
/// ```
pub const FILE_DESCRIPTOR_SET: &[u8] = include_bytes!("flight_descriptor.bin");
}

/// Defines a `Flight` for generation or retrieval.
pub mod flight_descriptor {
use super::gen;
pub use gen::flight_descriptor::DescriptorType;

pub use gen::FILE_DESCRIPTOR_SET;
}

/// Low Level [tonic] [`FlightServiceClient`](gen::flight_service_client::FlightServiceClient).
Expand Down
Binary file added arrow-flight/src/sql/flight_sql_descriptor.bin
Binary file not shown.
12 changes: 12 additions & 0 deletions arrow-flight/src/sql/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ mod gen {
// Since this file is auto-generated, we suppress all warnings
#![allow(missing_docs)]
include!("arrow.flight.protocol.sql.rs");

/// The descriptor used for making the Arrow Flight SQL gRPC API available for [gRPC
/// reflection](https://grpc.io/docs/guides/reflection/).
///
/// ```
/// let reflection_server = tonic_reflection::server::Builder::configure()
/// .register_encoded_file_descriptor_set(arrow_flight::sql::FILE_DESCRIPTOR_SET)
/// .build_v1()
/// .unwrap();
/// ```
pub const FILE_DESCRIPTOR_SET: &[u8] = include_bytes!("flight_sql_descriptor.bin");
}

pub use gen::action_end_transaction_request::EndTransaction;
Expand Down Expand Up @@ -109,6 +120,7 @@ pub use gen::TicketStatementQuery;
pub use gen::UpdateDeleteRules;
pub use gen::XdbcDataType;
pub use gen::XdbcDatetimeSubcode;
pub use gen::FILE_DESCRIPTOR_SET;

pub mod client;
pub mod metadata;
Expand Down

0 comments on commit 06b64bc

Please sign in to comment.