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:
|
|
|
|
///
|
2021-02-22 10:48:11 +00:00
|
|
|
/// - `com.github.influxdata.idpe.storage.read.rs`
|
2021-10-29 09:57:08 +00:00
|
|
|
/// - `influxdata.iox.delete.v1.rs`
|
2021-11-01 13:49:59 +00:00
|
|
|
/// - `influxdata.iox.deployment.v1.rs`
|
2021-02-22 10:48:11 +00:00
|
|
|
/// - `influxdata.iox.management.v1.rs`
|
2021-11-01 11:47:28 +00:00
|
|
|
/// - `influxdata.iox.preserved_catalog.v1.rs`
|
2021-10-29 09:21:25 +00:00
|
|
|
/// - `influxdata.iox.remote.v1.rs`
|
2021-10-21 08:35:09 +00:00
|
|
|
/// - `influxdata.iox.router.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<()> {
|
2021-10-29 09:57:08 +00:00
|
|
|
let delete_path = root.join("influxdata/iox/delete/v1");
|
2021-11-01 13:49:59 +00:00
|
|
|
let deployment_path = root.join("influxdata/iox/deployment/v1");
|
2021-10-20 06:56:03 +00:00
|
|
|
let idpe_path = root.join("com/github/influxdata/idpe/storage/read");
|
2021-02-22 10:48:11 +00:00
|
|
|
let management_path = root.join("influxdata/iox/management/v1");
|
2021-11-01 11:47:28 +00:00
|
|
|
let preserved_catalog_path = root.join("influxdata/iox/preserved_catalog/v1");
|
2021-10-29 09:21:25 +00:00
|
|
|
let remote_path = root.join("influxdata/iox/remote/v1");
|
2021-10-21 08:35:09 +00:00
|
|
|
let router_path = root.join("influxdata/iox/router/v1");
|
2021-10-20 06:56:03 +00:00
|
|
|
let storage_path = root.join("influxdata/platform/storage");
|
2021-11-01 16:34:38 +00:00
|
|
|
let write_buffer_path = root.join("influxdata/iox/write_buffer/v1");
|
2021-03-08 17:35:19 +00:00
|
|
|
let write_path = root.join("influxdata/iox/write/v1");
|
2021-02-22 10:48:11 +00:00
|
|
|
|
2020-11-11 20:20:53 +00:00
|
|
|
let proto_files = vec![
|
2021-10-29 09:57:08 +00:00
|
|
|
delete_path.join("service.proto"),
|
2021-11-01 13:49:59 +00:00
|
|
|
deployment_path.join("service.proto"),
|
2021-10-20 06:56:03 +00:00
|
|
|
idpe_path.join("source.proto"),
|
2021-03-12 13:56:14 +00:00
|
|
|
management_path.join("chunk.proto"),
|
2021-10-20 06:56:03 +00:00
|
|
|
management_path.join("database_rules.proto"),
|
|
|
|
management_path.join("jobs.proto"),
|
2021-03-11 19:33:04 +00:00
|
|
|
management_path.join("partition.proto"),
|
2021-10-20 08:51:54 +00:00
|
|
|
management_path.join("partition_template.proto"),
|
2021-10-13 18:44:21 +00:00
|
|
|
management_path.join("server_config.proto"),
|
2021-02-22 10:48:11 +00:00
|
|
|
management_path.join("service.proto"),
|
2021-03-19 09:19:13 +00:00
|
|
|
management_path.join("shard.proto"),
|
2021-11-01 11:47:28 +00:00
|
|
|
preserved_catalog_path.join("catalog.proto"),
|
|
|
|
preserved_catalog_path.join("parquet_metadata.proto"),
|
|
|
|
preserved_catalog_path.join("predicate.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"),
|
2021-10-29 09:21:25 +00:00
|
|
|
remote_path.join("remote.proto"),
|
|
|
|
remote_path.join("service.proto"),
|
2021-10-21 08:35:09 +00:00
|
|
|
router_path.join("router.proto"),
|
|
|
|
router_path.join("service.proto"),
|
2021-10-20 06:56:03 +00:00
|
|
|
storage_path.join("predicate.proto"),
|
|
|
|
storage_path.join("service.proto"),
|
|
|
|
storage_path.join("storage_common.proto"),
|
|
|
|
storage_path.join("storage_common_idpe.proto"),
|
|
|
|
storage_path.join("test.proto"),
|
|
|
|
write_path.join("service.proto"),
|
2021-11-01 16:34:38 +00:00
|
|
|
write_buffer_path.join("write_buffer.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()
|
2021-03-10 17:34:07 +00:00
|
|
|
.disable_comments(&[".google"])
|
2021-09-28 16:29:26 +00:00
|
|
|
.extern_path(".google.protobuf", "::pbjson_types")
|
2021-10-05 10:27:48 +00:00
|
|
|
.bytes(&[
|
2021-10-06 07:44:41 +00:00
|
|
|
".influxdata.iox.management.v1.Chunk.id",
|
|
|
|
".influxdata.iox.management.v1.ClosePartitionChunkRequest.chunk_id",
|
|
|
|
".influxdata.iox.management.v1.CompactChunks.chunks",
|
|
|
|
".influxdata.iox.management.v1.DropChunk.chunk_id",
|
|
|
|
".influxdata.iox.management.v1.PersistChunks.chunks",
|
|
|
|
".influxdata.iox.management.v1.WriteChunk.chunk_id",
|
|
|
|
".influxdata.iox.management.v1.UnloadPartitionChunkRequest.chunk_id",
|
2021-11-01 11:47:28 +00:00
|
|
|
".influxdata.iox.preserved_catalog.v1.AddParquet.metadata",
|
|
|
|
".influxdata.iox.preserved_catalog.v1.ChunkAddr.chunk_id",
|
|
|
|
".influxdata.iox.preserved_catalog.v1.IoxMetadata.chunk_id",
|
|
|
|
".influxdata.iox.preserved_catalog.v1.Transaction.previous_uuid",
|
|
|
|
".influxdata.iox.preserved_catalog.v1.Transaction.uuid",
|
2021-10-14 10:55:51 +00:00
|
|
|
".influxdata.iox.write.v1.WriteEntryRequest.entry",
|
2021-10-05 10:27:48 +00:00
|
|
|
])
|
2021-09-13 10:06:20 +00:00
|
|
|
.btree_map(&[
|
2021-11-01 11:47:28 +00:00
|
|
|
".influxdata.iox.preserved_catalog.v1.DatabaseCheckpoint.sequencer_numbers",
|
|
|
|
".influxdata.iox.preserved_catalog.v1.PartitionCheckpoint.sequencer_numbers",
|
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)
|
|
|
|
.format(true)
|
|
|
|
.compile_with_config(config, &proto_files, &[root.into()])?;
|
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)?
|
|
|
|
.build(&[".influxdata", ".google.longrunning", ".google.rpc"])?;
|
|
|
|
|
2020-06-05 20:22:27 +00:00
|
|
|
Ok(())
|
|
|
|
}
|