influxdb/generated_types/build.rs

117 lines
4.4 KiB
Rust
Raw Normal View History

//! Compiles Protocol Buffers into native Rust types.
2021-05-05 19:52:55 +00:00
use std::env;
use std::path::{Path, PathBuf};
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");
generate_grpc_types(&root)?;
Ok(())
}
/// Schema used with IOx specific gRPC requests
///
/// Creates:
///
feat(authz): authorization service client and write integration (#7216) * feat(authz): add authorization client. Add a new authz crate to provide the interface for making authorization checks from within IOx. This includes the default client that uses the influxdata.iox.authz.v1 gRPC protocol. This feature is not used by any IOx component yet. * feat: optional authorization on write path Support optionally enabling authorization checks on the /api/v2/write handler. If an authrorizer is configured then the handler will attempt to retrieve a token from the request's Authorization header. If no such token exists then a response with a 401 error code is returned. If the token is not valid, or does not have write permission for the requested namespace then a response with a 403 error is returned. * chore: add unit test for authz in write handler Add unit tests that test the correct functioning of the /api/v2/write handler when an Authorizer is configured. * chore(authz): use lazy connection Change the initialization of the authz client to use a lazy connection. This allows the client to be initialised synchronously. * chore: Run cargo hakari tasks * fix(authz): protolint complaints * fix: authz tests * fix: benches and lint * chore: Update clap_blocks/src/authz.rs Co-authored-by: Marko Mikulicic <mkm@influxdata.com> * chore: Update authz/src/lib.rs Co-authored-by: Marko Mikulicic <mkm@influxdata.com> * chore: Update clap_blocks/src/authz.rs Co-authored-by: Marko Mikulicic <mkm@influxdata.com> * chore: review suggestions * chore: review suggestions Apply a number of suggestions from review comments. The main behavioural change is that if the authz service is configured applictions will perform a probe request to ensure it can communicate before continuing startup. * chore: Update router/src/server/http.rs Co-authored-by: Dom <dom@itsallbroken.com> --------- Co-authored-by: CircleCI[bot] <circleci@influxdata.com> Co-authored-by: Marko Mikulicic <mkm@influxdata.com> Co-authored-by: Dom <dom@itsallbroken.com>
2023-03-17 15:20:14 +00:00
/// - `influxdata.iox.authz.v1.rs`
/// - `influxdata.iox.catalog.v1.rs`
/// - `influxdata.iox.compactor.v1.rs`
2021-10-29 09:57:08 +00:00
/// - `influxdata.iox.delete.v1.rs`
/// - `influxdata.iox.ingester.v1.rs`
/// - `influxdata.iox.namespace.v1.rs`
/// - `influxdata.iox.object_store.v1.rs`
/// - `influxdata.iox.predicate.v1.rs`
/// - `influxdata.iox.querier.v1.rs`
/// - `influxdata.iox.schema.v1.rs`
/// - `influxdata.iox.wal.v1.rs`
/// - `influxdata.iox.write.v1.rs`
/// - `influxdata.platform.storage.rs`
fn generate_grpc_types(root: &Path) -> Result<()> {
feat(authz): authorization service client and write integration (#7216) * feat(authz): add authorization client. Add a new authz crate to provide the interface for making authorization checks from within IOx. This includes the default client that uses the influxdata.iox.authz.v1 gRPC protocol. This feature is not used by any IOx component yet. * feat: optional authorization on write path Support optionally enabling authorization checks on the /api/v2/write handler. If an authrorizer is configured then the handler will attempt to retrieve a token from the request's Authorization header. If no such token exists then a response with a 401 error code is returned. If the token is not valid, or does not have write permission for the requested namespace then a response with a 403 error is returned. * chore: add unit test for authz in write handler Add unit tests that test the correct functioning of the /api/v2/write handler when an Authorizer is configured. * chore(authz): use lazy connection Change the initialization of the authz client to use a lazy connection. This allows the client to be initialised synchronously. * chore: Run cargo hakari tasks * fix(authz): protolint complaints * fix: authz tests * fix: benches and lint * chore: Update clap_blocks/src/authz.rs Co-authored-by: Marko Mikulicic <mkm@influxdata.com> * chore: Update authz/src/lib.rs Co-authored-by: Marko Mikulicic <mkm@influxdata.com> * chore: Update clap_blocks/src/authz.rs Co-authored-by: Marko Mikulicic <mkm@influxdata.com> * chore: review suggestions * chore: review suggestions Apply a number of suggestions from review comments. The main behavioural change is that if the authz service is configured applictions will perform a probe request to ensure it can communicate before continuing startup. * chore: Update router/src/server/http.rs Co-authored-by: Dom <dom@itsallbroken.com> --------- Co-authored-by: CircleCI[bot] <circleci@influxdata.com> Co-authored-by: Marko Mikulicic <mkm@influxdata.com> Co-authored-by: Dom <dom@itsallbroken.com>
2023-03-17 15:20:14 +00:00
let authz_path = root.join("influxdata/iox/authz/v1");
let catalog_path = root.join("influxdata/iox/catalog/v1");
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");
let ingester_path = root.join("influxdata/iox/ingester/v1");
let namespace_path = root.join("influxdata/iox/namespace/v1");
let object_store_path = root.join("influxdata/iox/object_store/v1");
let partition_template_path = root.join("influxdata/iox/partition_template/v1");
let predicate_path = root.join("influxdata/iox/predicate/v1");
let querier_path = root.join("influxdata/iox/querier/v1");
let schema_path = root.join("influxdata/iox/schema/v1");
let storage_errors_path = root.join("influxdata/platform/errors");
let storage_path = root.join("influxdata/platform/storage");
let wal_path = root.join("influxdata/iox/wal/v1");
2021-02-22 10:48:11 +00:00
let proto_files = vec![
feat(authz): authorization service client and write integration (#7216) * feat(authz): add authorization client. Add a new authz crate to provide the interface for making authorization checks from within IOx. This includes the default client that uses the influxdata.iox.authz.v1 gRPC protocol. This feature is not used by any IOx component yet. * feat: optional authorization on write path Support optionally enabling authorization checks on the /api/v2/write handler. If an authrorizer is configured then the handler will attempt to retrieve a token from the request's Authorization header. If no such token exists then a response with a 401 error code is returned. If the token is not valid, or does not have write permission for the requested namespace then a response with a 403 error is returned. * chore: add unit test for authz in write handler Add unit tests that test the correct functioning of the /api/v2/write handler when an Authorizer is configured. * chore(authz): use lazy connection Change the initialization of the authz client to use a lazy connection. This allows the client to be initialised synchronously. * chore: Run cargo hakari tasks * fix(authz): protolint complaints * fix: authz tests * fix: benches and lint * chore: Update clap_blocks/src/authz.rs Co-authored-by: Marko Mikulicic <mkm@influxdata.com> * chore: Update authz/src/lib.rs Co-authored-by: Marko Mikulicic <mkm@influxdata.com> * chore: Update clap_blocks/src/authz.rs Co-authored-by: Marko Mikulicic <mkm@influxdata.com> * chore: review suggestions * chore: review suggestions Apply a number of suggestions from review comments. The main behavioural change is that if the authz service is configured applictions will perform a probe request to ensure it can communicate before continuing startup. * chore: Update router/src/server/http.rs Co-authored-by: Dom <dom@itsallbroken.com> --------- Co-authored-by: CircleCI[bot] <circleci@influxdata.com> Co-authored-by: Marko Mikulicic <mkm@influxdata.com> Co-authored-by: Dom <dom@itsallbroken.com>
2023-03-17 15:20:14 +00:00
authz_path.join("authz.proto"),
catalog_path.join("parquet_file.proto"),
catalog_path.join("service.proto"),
compactor_path.join("service.proto"),
2021-10-29 09:57:08 +00:00
delete_path.join("service.proto"),
ingester_path.join("parquet_metadata.proto"),
ingester_path.join("persist.proto"),
ingester_path.join("replication.proto"),
ingester_path.join("write.proto"),
namespace_path.join("service.proto"),
object_store_path.join("service.proto"),
partition_template_path.join("template.proto"),
predicate_path.join("predicate.proto"),
querier_path.join("flight.proto"),
root.join("google/longrunning/operations.proto"),
root.join("google/rpc/error_details.proto"),
root.join("google/rpc/status.proto"),
root.join("grpc/health/v1/service.proto"),
root.join("influxdata/pbdata/v1/influxdb_pb_data_protocol.proto"),
schema_path.join("service.proto"),
storage_errors_path.join("errors.proto"),
storage_path.join("predicate.proto"),
storage_path.join("service.proto"),
2021-11-22 12:40:29 +00:00
storage_path.join("source.proto"),
storage_path.join("storage_common.proto"),
storage_path.join("test.proto"),
wal_path.join("wal.proto"),
];
// 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());
}
let mut config = prost_build::Config::new();
config
.compile_well_known_types()
.disable_comments([".google"])
.extern_path(".google.protobuf", "::pbjson_types")
.btree_map([
refactor: querier<>ingester flight protocol adjustments (#4286) * refactor: querier<>ingester flight protocol adjustments This makes a few adjustments to the querier<>ingester flight protocol. Query Scope =========== The querier will request data for ALL sequencer IDs for now. There is no reason to have a request per sequencer ID. We can add a range/set filter later if we want, but this is not required for now. Partition-level =============== The only time when the querier cares about sequencer IDs (i.e. sharding) at all is when it selects which ingesters to ask for unpersisted data (this is currently not implemented, it just asks all ingesters). Afterwards the querier only cares about partitions (which are bound to specific sequencers anyways) because this is the level where parquet file persistence and compaction as well as deduplication happen. So we make partitions a first-class citizen in the ingester response. Metadata VS RecordBatches ========================= The global app-metadata will list all partitions and their max persisted parquet files and tombstones (theoretically tombstones are at table-level, but the ingester could in the future break them down to the partition-level). Then it receives a stream of record batches. Each record batch is tagged (via key-value metadata in its schema) so it can be assigned to a partition. At the moment the ingester returns 0 or 1 batches per unpersisted partition (0 in case we've filtered out all the data via the predicate), but in the future it is free to return multiple batches. This setup gives the ingester more freedom over memory management and (potentially parallel) query processing, while at the same time keeps the set of duplicated information minimal and allows easy extensions (since the global metadata is a full-blown protobuf message). Querier ======= At the moment the querier ignores all the metdata. Follow-up PRs will change that. * docs: improve Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org> * refactor: make code clearer Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
2022-04-12 16:48:40 +00:00
".influxdata.iox.ingester.v1.IngesterQueryResponseMetadata.unpersisted_partitions",
]);
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)
// protoc in ubuntu builder needs this option
.protoc_arg("--experimental_allow_proto3_optional")
.compile_with_config(config, &proto_files, &[root])?;
let descriptor_set = std::fs::read(descriptor_path)?;
pbjson_build::Builder::new()
.register_descriptors(&descriptor_set)?
.build(&[
".influxdata.iox",
".influxdata.pbdata",
".influxdata.platform.storage",
".influxdata.platform.errors",
".google.longrunning",
".google.rpc",
])?;
Ok(())
}