2021-03-18 17:43:58 +00:00
|
|
|
//! Compiles Protocol Buffers into native Rust types.
|
2020-06-05 20:22:27 +00:00
|
|
|
|
2021-05-05 19:52:55 +00:00
|
|
|
use std::env;
|
2021-03-18 17:43:58 +00:00
|
|
|
use std::path::{Path, PathBuf};
|
2020-06-05 20:22:27 +00:00
|
|
|
|
|
|
|
type Error = Box<dyn std::error::Error>;
|
|
|
|
type Result<T, E = Error> = std::result::Result<T, E>;
|
|
|
|
|
|
|
|
fn main() -> Result<()> {
|
2021-02-22 10:48:11 +00:00
|
|
|
let root = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("protos");
|
2020-06-05 20:22:27 +00:00
|
|
|
|
|
|
|
generate_grpc_types(&root)?;
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2020-11-11 20:20:53 +00:00
|
|
|
/// Schema used with IOx specific gRPC requests
|
2020-06-05 20:22:27 +00:00
|
|
|
///
|
2021-04-29 16:07:49 +00:00
|
|
|
/// Creates:
|
|
|
|
///
|
2022-04-14 17:39:18 +00:00
|
|
|
/// - `influxdata.iox.catalog.v1.rs`
|
2022-10-19 15:03:07 +00:00
|
|
|
/// - `influxdata.iox.compactor.v1.rs`
|
2021-10-29 09:57:08 +00:00
|
|
|
/// - `influxdata.iox.delete.v1.rs`
|
2022-02-09 19:07:44 +00:00
|
|
|
/// - `influxdata.iox.ingester.v1.rs`
|
2022-03-31 12:57:33 +00:00
|
|
|
/// - `influxdata.iox.namespace.v1.rs`
|
2022-04-29 20:07:33 +00:00
|
|
|
/// - `influxdata.iox.object_store.v1.rs`
|
|
|
|
/// - `influxdata.iox.predicate.v1.rs`
|
2022-04-12 09:08:25 +00:00
|
|
|
/// - `influxdata.iox.querier.v1.rs`
|
2022-03-22 11:27:20 +00:00
|
|
|
/// - `influxdata.iox.schema.v1.rs`
|
2022-08-23 13:44:37 +00:00
|
|
|
/// - `influxdata.iox.sharder.v1.rs`
|
2022-11-23 18:54:54 +00:00
|
|
|
/// - `influxdata.iox.wal.v1.rs`
|
2021-04-29 16:07:49 +00:00
|
|
|
/// - `influxdata.iox.write.v1.rs`
|
2021-11-01 16:34:38 +00:00
|
|
|
/// - `influxdata.iox.write_buffer.v1.rs`
|
2021-04-29 16:07:49 +00:00
|
|
|
/// - `influxdata.platform.storage.rs`
|
2020-06-05 20:22:27 +00:00
|
|
|
fn generate_grpc_types(root: &Path) -> Result<()> {
|
2022-04-14 17:39:18 +00:00
|
|
|
let catalog_path = root.join("influxdata/iox/catalog/v1");
|
2022-10-19 15:03:07 +00:00
|
|
|
let compactor_path = root.join("influxdata/iox/compactor/v1");
|
2021-10-29 09:57:08 +00:00
|
|
|
let delete_path = root.join("influxdata/iox/delete/v1");
|
2022-02-09 19:07:44 +00:00
|
|
|
let ingester_path = root.join("influxdata/iox/ingester/v1");
|
2022-03-31 12:57:33 +00:00
|
|
|
let namespace_path = root.join("influxdata/iox/namespace/v1");
|
2022-04-16 17:58:31 +00:00
|
|
|
let object_store_path = root.join("influxdata/iox/object_store/v1");
|
2021-11-08 13:42:26 +00:00
|
|
|
let predicate_path = root.join("influxdata/iox/predicate/v1");
|
2022-04-12 09:08:25 +00:00
|
|
|
let querier_path = root.join("influxdata/iox/querier/v1");
|
2022-03-22 11:27:20 +00:00
|
|
|
let schema_path = root.join("influxdata/iox/schema/v1");
|
2022-08-23 13:44:37 +00:00
|
|
|
let sharder_path = root.join("influxdata/iox/sharder/v1");
|
2022-11-23 18:54:54 +00:00
|
|
|
let wal_path = root.join("influxdata/iox/wal/v1");
|
2021-11-01 16:34:38 +00:00
|
|
|
let write_buffer_path = root.join("influxdata/iox/write_buffer/v1");
|
2022-04-02 10:34:51 +00:00
|
|
|
let write_summary_path = root.join("influxdata/iox/write_summary/v1");
|
2022-04-29 20:07:33 +00:00
|
|
|
let storage_path = root.join("influxdata/platform/storage");
|
2022-11-17 19:51:01 +00:00
|
|
|
let storage_errors_path = root.join("influxdata/platform/errors");
|
2021-02-22 10:48:11 +00:00
|
|
|
|
2020-11-11 20:20:53 +00:00
|
|
|
let proto_files = vec![
|
2022-04-14 17:39:18 +00:00
|
|
|
catalog_path.join("parquet_file.proto"),
|
|
|
|
catalog_path.join("service.proto"),
|
2022-10-21 16:42:06 +00:00
|
|
|
compactor_path.join("service.proto"),
|
2021-10-29 09:57:08 +00:00
|
|
|
delete_path.join("service.proto"),
|
2022-02-09 19:07:44 +00:00
|
|
|
ingester_path.join("parquet_metadata.proto"),
|
|
|
|
ingester_path.join("query.proto"),
|
2022-04-07 19:24:58 +00:00
|
|
|
ingester_path.join("write_info.proto"),
|
2022-11-14 09:41:39 +00:00
|
|
|
ingester_path.join("write.proto"),
|
2023-01-04 16:37:32 +00:00
|
|
|
ingester_path.join("replication.proto"),
|
2022-03-31 12:57:33 +00:00
|
|
|
namespace_path.join("service.proto"),
|
2022-04-16 17:58:31 +00:00
|
|
|
object_store_path.join("service.proto"),
|
2021-11-08 13:42:26 +00:00
|
|
|
predicate_path.join("predicate.proto"),
|
2022-04-12 09:08:25 +00:00
|
|
|
querier_path.join("flight.proto"),
|
2021-03-10 17:34:07 +00:00
|
|
|
root.join("google/longrunning/operations.proto"),
|
|
|
|
root.join("google/rpc/error_details.proto"),
|
|
|
|
root.join("google/rpc/status.proto"),
|
2021-10-20 06:56:03 +00:00
|
|
|
root.join("grpc/health/v1/service.proto"),
|
|
|
|
root.join("influxdata/pbdata/v1/influxdb_pb_data_protocol.proto"),
|
2022-03-22 11:27:20 +00:00
|
|
|
schema_path.join("service.proto"),
|
2022-08-23 13:44:37 +00:00
|
|
|
sharder_path.join("sharder.proto"),
|
2022-11-23 18:54:54 +00:00
|
|
|
wal_path.join("wal.proto"),
|
2022-04-29 20:07:33 +00:00
|
|
|
write_buffer_path.join("write_buffer.proto"),
|
|
|
|
write_summary_path.join("write_summary.proto"),
|
2021-10-20 06:56:03 +00:00
|
|
|
storage_path.join("predicate.proto"),
|
|
|
|
storage_path.join("service.proto"),
|
2021-11-22 12:40:29 +00:00
|
|
|
storage_path.join("source.proto"),
|
2021-10-20 06:56:03 +00:00
|
|
|
storage_path.join("storage_common.proto"),
|
|
|
|
storage_path.join("test.proto"),
|
2022-11-17 19:51:01 +00:00
|
|
|
storage_errors_path.join("errors.proto"),
|
2020-11-11 20:20:53 +00:00
|
|
|
];
|
2020-06-05 20:22:27 +00:00
|
|
|
|
2020-11-11 20:20:53 +00:00
|
|
|
// Tell cargo to recompile if any of these proto files are changed
|
|
|
|
for proto_file in &proto_files {
|
|
|
|
println!("cargo:rerun-if-changed={}", proto_file.display());
|
|
|
|
}
|
|
|
|
|
2021-02-12 16:14:53 +00:00
|
|
|
let mut config = prost_build::Config::new();
|
|
|
|
|
|
|
|
config
|
|
|
|
.compile_well_known_types()
|
2022-11-04 15:33:52 +00:00
|
|
|
.disable_comments([".google"])
|
2021-09-28 16:29:26 +00:00
|
|
|
.extern_path(".google.protobuf", "::pbjson_types")
|
2022-11-04 15:33:52 +00:00
|
|
|
.btree_map([
|
2022-04-12 16:48:40 +00:00
|
|
|
".influxdata.iox.ingester.v1.IngesterQueryResponseMetadata.unpersisted_partitions",
|
2021-09-13 10:06:20 +00:00
|
|
|
]);
|
2021-02-12 16:14:53 +00:00
|
|
|
|
2021-05-05 19:52:55 +00:00
|
|
|
let descriptor_path = PathBuf::from(env::var("OUT_DIR").unwrap()).join("proto_descriptor.bin");
|
|
|
|
tonic_build::configure()
|
|
|
|
.file_descriptor_set_path(&descriptor_path)
|
2022-04-29 20:07:33 +00:00
|
|
|
// protoc in ubuntu builder needs this option
|
2022-04-20 11:12:17 +00:00
|
|
|
.protoc_arg("--experimental_allow_proto3_optional")
|
2022-01-13 17:07:15 +00:00
|
|
|
.compile_with_config(config, &proto_files, &[root])?;
|
2020-06-05 20:22:27 +00:00
|
|
|
|
2021-09-16 07:33:27 +00:00
|
|
|
let descriptor_set = std::fs::read(descriptor_path)?;
|
|
|
|
|
|
|
|
pbjson_build::Builder::new()
|
|
|
|
.register_descriptors(&descriptor_set)?
|
2021-11-22 17:48:31 +00:00
|
|
|
.build(&[
|
|
|
|
".influxdata.iox",
|
|
|
|
".influxdata.pbdata",
|
2021-12-07 16:39:16 +00:00
|
|
|
".influxdata.platform.storage",
|
2022-11-17 19:51:01 +00:00
|
|
|
".influxdata.platform.errors",
|
2021-11-22 17:48:31 +00:00
|
|
|
".google.longrunning",
|
|
|
|
".google.rpc",
|
|
|
|
])?;
|
2021-09-16 07:33:27 +00:00
|
|
|
|
2020-06-05 20:22:27 +00:00
|
|
|
Ok(())
|
|
|
|
}
|