Skip to content

Commit

Permalink
update grpc-proto to 22.2 with null type, empty list, etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
rekby committed Apr 3, 2022
1 parent 91754fc commit 9fad323
Show file tree
Hide file tree
Showing 32 changed files with 2,345 additions and 72 deletions.
51 changes: 47 additions & 4 deletions ydb-grpc/build.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use ydb_grpc_helpers::ProtoModule;
use std::cmp::Ordering;
use std::collections::HashMap;
use std::fs;
use std::io::{Read, Write};
use std::fs::OpenOptions;
use std::io::{Read, Seek, SeekFrom, Write};
use std::{fs, io};
use walkdir::WalkDir;
use ydb_grpc_helpers::ProtoModule;

const COMPILE_DIRS: &[(&str, &str)] = &[
// src, dst
Expand All @@ -20,12 +22,13 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {

if std::env::var("CARGO_FEATURE_REGENERATE_SOURCES").unwrap_or("0".into()) != "1" {
println!("skip regenerate sources");
return Ok(())
return Ok(());
}

for (src, dst) in COMPILE_DIRS {
clean_dst_dir(dst)?;
compile_proto_dir(src, INCLUDE_DIRS, dst)?;
rewrite_generated_files(dst)?;
generate_mod_file(dst)?;
}

Expand Down Expand Up @@ -59,6 +62,46 @@ fn compile_files(files: &[&str], include_dirs: &[&str], dst_dir: &str) {
.expect("failed to compile protobuf");
}

fn rewrite_generated_file(fpath: &std::path::Path) -> io::Result<()> {
println!("rewrite file: '{}'", fpath.to_str().unwrap_or("<empty>"));
let mut f = OpenOptions::new().read(true).write(true).open(fpath)?;
let mut contents = String::new();
let _ = f.read_to_string(&mut contents).unwrap();

let lines: Vec<&str> = contents
.split_terminator("\n")
.filter(|line| line.trim() != "///")
.collect();

println!("1");
let contents = lines.join("\n");
f.seek(SeekFrom::Start(0))?;
f.set_len(0)?;
println!("2");
f.write_all(contents.as_bytes())?;
println!("3");
return Ok(());
}

fn rewrite_generated_files(dir: &str) -> io::Result<()> {
for item in WalkDir::new(dir) {
let item = item?;
let item_path = item.path().to_str().unwrap_or("<empty>");
if !item.path().ends_with(".rs") {
println!("skip rewrite file: '{}'", item_path)
}
if !item.metadata()?.is_file() {
println!("skip not file: '{}'", item_path);
continue;
}
println!("rewrite file '{}'", item_path);

rewrite_generated_file(item.path())?;
}

return Ok(());
}

fn compile_proto_dir(
src_dir: &str,
include_dirs: &[&str],
Expand Down
1 change: 0 additions & 1 deletion ydb-grpc/src/generated/google.protobuf.rs
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@

11 changes: 11 additions & 0 deletions ydb-grpc/src/generated/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ pub mod ydb {
include!("ydb.export.v1.rs");
}
}
pub mod formats {
include!("ydb.formats.rs");
}
pub mod import {
include!("ydb.import.rs");
pub mod v1 {
Expand All @@ -52,6 +55,14 @@ pub mod ydb {
pub mod operations {
include!("ydb.operations.rs");
}
pub mod pers_queue {
pub mod cluster_discovery {
include!("ydb.pers_queue.cluster_discovery.rs");
}
pub mod v1 {
include!("ydb.pers_queue.v1.rs");
}
}
pub mod rate_limiter {
include!("ydb.rate_limiter.rs");
pub mod v1 {
Expand Down
25 changes: 15 additions & 10 deletions ydb-grpc/src/generated/ydb.cms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,6 @@ pub struct DatabaseOptions {
#[prost(uint32, tag = "3")]
pub plan_resolution: u32,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Attribute {
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub value: ::prost::alloc::string::String,
}
/// A set of quotas for schema operations
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SchemaOperationQuotas {
Expand Down Expand Up @@ -110,6 +103,13 @@ pub struct DatabaseQuotas {
/// A maximum count of shards in all data streams.
#[prost(uint64, tag = "3")]
pub data_stream_shards_quota: u64,
/// A maximum storage that will be reserved for all data stream shards.
#[prost(uint64, tag = "5")]
pub data_stream_reserved_storage_quota: u64,
/// A minimum value of `TtlSettings.run_interval_seconds` that can be specified.
/// Default is 1800 (15 minutes).
#[prost(uint32, tag = "4")]
pub ttl_min_run_internal_seconds: u32,
}
/// Request to create a new database. For successfull creation
/// specified database shouldn't exist. At least one storage
Expand All @@ -125,8 +125,9 @@ pub struct CreateDatabaseRequest {
#[prost(message, optional, tag = "4")]
pub options: ::core::option::Option<DatabaseOptions>,
/// Attach attributes to database.
#[prost(message, repeated, tag = "5")]
pub attributes: ::prost::alloc::vec::Vec<Attribute>,
#[prost(map = "string, string", tag = "5")]
pub attributes:
::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::string::String>,
/// Optional quotas for schema operations
#[prost(message, optional, tag = "8")]
pub schema_operation_quotas: ::core::option::Option<SchemaOperationQuotas>,
Expand Down Expand Up @@ -261,6 +262,10 @@ pub struct AlterDatabaseRequest {
/// Change quotas for the database
#[prost(message, optional, tag = "11")]
pub database_quotas: ::core::option::Option<DatabaseQuotas>,
/// Alter attributes. Leave the value blank to drop an attribute.
#[prost(map = "string, string", tag = "12")]
pub alter_attributes:
::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::string::String>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AlterDatabaseResponse {
Expand Down Expand Up @@ -345,4 +350,4 @@ pub struct DescribeDatabaseOptionsResult {
pub availability_zones: ::prost::alloc::vec::Vec<AvailabilityZoneDescription>,
#[prost(message, repeated, tag = "3")]
pub computational_units: ::prost::alloc::vec::Vec<ComputationalUnitDescription>,
}
}
2 changes: 1 addition & 1 deletion ydb-grpc/src/generated/ydb.cms.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,4 @@ pub mod cms_service_client {
self.inner.unary(request.into_request(), path, codec).await
}
}
}
}
13 changes: 3 additions & 10 deletions ydb-grpc/src/generated/ydb.coordination.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
///*
/// Stub for unsupported messages
///
/// Intentionally empty
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Unsupported {}
Expand All @@ -14,7 +13,7 @@ pub struct Config {
/// Period in milliseconds for self-checks (default 1 second)
#[prost(uint32, tag = "2")]
pub self_check_period_millis: u32,
/// Grace period for sessions on master change (default 10 seconds)
/// Grace period for sessions on leader change (default 10 seconds)
#[prost(uint32, tag = "3")]
pub session_grace_period_millis: u32,
/// Concistency mode for read operations
Expand Down Expand Up @@ -137,15 +136,12 @@ pub mod session_request {
}
///*
/// Last message used to cleanly stop session before its timeout expires
///
/// nothing
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SessionStop {}
///*
/// Used to acquire a semaphore
///
/// WARNING: a single session cannot acquire the same semaphore multiple times
///
/// Later requests override previous operations with the same semaphore,
/// e.g. to reduce acquired count, change timeout or attached data.
#[derive(Clone, PartialEq, ::prost::Message)]
Expand Down Expand Up @@ -173,9 +169,7 @@ pub mod session_request {
}
///*
/// Used to release a semaphore
///
/// WARNING: a single session cannot release the same semaphore multiple times
///
/// The release operation will either remove current session from waiters
/// queue or release an already owned semaphore.
#[derive(Clone, PartialEq, ::prost::Message)]
Expand All @@ -189,7 +183,6 @@ pub mod session_request {
}
///*
/// Used to describe semaphores and watch them for changes
///
/// WARNING: a describe operation will cancel previous watches on the same semaphore
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DescribeSemaphore {
Expand Down Expand Up @@ -539,7 +532,7 @@ pub struct DescribeNodeResult {
pub enum ConsistencyMode {
/// The default or current value
Unset = 0,
/// Strict mode makes sure operations may only complete on current master
/// Strict mode makes sure operations may only complete on current leader
Strict = 1,
/// Relaxed mode allows operations to complete on stale masters
Relaxed = 2,
Expand All @@ -555,4 +548,4 @@ pub enum RateLimiterCountersMode {
Aggregated = 1,
/// Counters on every resource
Detailed = 2,
}
}
2 changes: 1 addition & 1 deletion ydb-grpc/src/generated/ydb.coordination.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,4 @@ pub mod coordination_service_client {
self.inner.unary(request.into_request(), path, codec).await
}
}
}
}
15 changes: 14 additions & 1 deletion ydb-grpc/src/generated/ydb.discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pub struct ListEndpointsRequest {
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct EndpointInfo {
/// This is an address (usually fqdn) and port of this node's grpc endpoint
#[prost(string, tag = "1")]
pub address: ::prost::alloc::string::String,
#[prost(uint32, tag = "2")]
Expand All @@ -21,6 +22,18 @@ pub struct EndpointInfo {
pub location: ::prost::alloc::string::String,
#[prost(uint32, tag = "7")]
pub node_id: u32,
/// Optional ipv4 and/or ipv6 addresses of the endpoint, which clients may
/// use instead of a dns name in the address field.
#[prost(string, repeated, tag = "8")]
pub ip_v4: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
#[prost(string, repeated, tag = "9")]
pub ip_v6: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
/// Optional value for grpc.ssl_target_name_override option that must be
/// used when connecting to this endpoint. This may be specified when an ssl
/// endpoint is using certificate chain valid for a balancer hostname, and
/// not this specific node hostname.
#[prost(string, tag = "10")]
pub ssl_target_name_override: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListEndpointsResult {
Expand Down Expand Up @@ -53,4 +66,4 @@ pub struct WhoAmIResult {
pub struct WhoAmIResponse {
#[prost(message, optional, tag = "1")]
pub operation: ::core::option::Option<super::operations::Operation>,
}
}
2 changes: 1 addition & 1 deletion ydb-grpc/src/generated/ydb.discovery.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,4 @@ pub mod discovery_service_client {
self.inner.unary(request.into_request(), path, codec).await
}
}
}
}
2 changes: 1 addition & 1 deletion ydb-grpc/src/generated/ydb.export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,4 @@ pub struct ExportToS3Response {
/// operation.metadata = ExportToS3Metadata
#[prost(message, optional, tag = "1")]
pub operation: ::core::option::Option<super::operations::Operation>,
}
}
2 changes: 1 addition & 1 deletion ydb-grpc/src/generated/ydb.export.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,4 @@ pub mod export_service_client {
self.inner.unary(request.into_request(), path, codec).await
}
}
}
}
20 changes: 20 additions & 0 deletions ydb-grpc/src/generated/ydb.formats.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ArrowBatchSettings {
#[prost(bytes = "vec", tag = "1")]
pub schema: ::prost::alloc::vec::Vec<u8>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CsvSettings {
/// Number of rows to skip before CSV data. It should be present only in the first upsert of CSV file.
#[prost(uint32, tag = "1")]
pub skip_rows: u32,
/// Fields delimiter in CSV file. It's "," if not set.
#[prost(bytes = "vec", tag = "2")]
pub delimiter: ::prost::alloc::vec::Vec<u8>,
/// String value that would be interpreted as NULL.
#[prost(bytes = "vec", tag = "3")]
pub null_value: ::prost::alloc::vec::Vec<u8>,
/// First not skipped line is a CSV header (list of column names).
#[prost(bool, tag = "4")]
pub header: bool,
}
2 changes: 1 addition & 1 deletion ydb-grpc/src/generated/ydb.import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,4 @@ pub struct ImportDataResponse {
/// operation.result = ImportDataResult
#[prost(message, optional, tag = "1")]
pub operation: ::core::option::Option<super::operations::Operation>,
}
}
2 changes: 1 addition & 1 deletion ydb-grpc/src/generated/ydb.import.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,4 @@ pub mod import_service_client {
self.inner.unary(request.into_request(), path, codec).await
}
}
}
}
6 changes: 3 additions & 3 deletions ydb-grpc/src/generated/ydb.issue.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// IssueMessage is a transport format for yql/public/issue library
/// IssueMessage is a transport format for ydb/library/yql/public/issue library
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct IssueMessage {
#[prost(message, optional, tag = "1")]
Expand All @@ -9,7 +9,7 @@ pub struct IssueMessage {
pub end_position: ::core::option::Option<issue_message::Position>,
#[prost(uint32, tag = "4")]
pub issue_code: u32,
/// Severity values from yql/public/issue/protos/issue_severity.proto
/// Severity values from ydb/library/yql/public/issue/protos/issue_severity.proto
/// FATAL = 0;
/// ERROR = 1;
/// WARNING = 2;
Expand All @@ -30,4 +30,4 @@ pub mod issue_message {
#[prost(string, tag = "3")]
pub file: ::prost::alloc::string::String,
}
}
}
6 changes: 5 additions & 1 deletion ydb-grpc/src/generated/ydb.monitoring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,16 @@ pub mod status_flag {
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SelfCheckRequest {
/// basic operation params, including timeout
#[prost(message, optional, tag = "1")]
pub operation_params: ::core::option::Option<super::operations::OperationParams>,
/// return detailed info about components checked with their statuses
#[prost(bool, tag = "2")]
pub return_verbose_status: bool,
/// minimum status of issues to return
#[prost(enumeration = "status_flag::Status", tag = "3")]
pub minimum_status: i32,
/// maximum level of issues to return
#[prost(uint32, tag = "4")]
pub maximum_level: u32,
}
Expand Down Expand Up @@ -263,4 +267,4 @@ pub struct SelfCheckResult {
pub issue_log: ::prost::alloc::vec::Vec<IssueLog>,
#[prost(message, repeated, tag = "3")]
pub database_status: ::prost::alloc::vec::Vec<DatabaseStatus>,
}
}
2 changes: 1 addition & 1 deletion ydb-grpc/src/generated/ydb.monitoring.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ pub mod monitoring_service_client {
self.inner.unary(request.into_request(), path, codec).await
}
}
}
}
2 changes: 1 addition & 1 deletion ydb-grpc/src/generated/ydb.operation.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,4 @@ pub mod operation_service_client {
self.inner.unary(request.into_request(), path, codec).await
}
}
}
}
2 changes: 1 addition & 1 deletion ydb-grpc/src/generated/ydb.operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,4 @@ pub struct Operation {
/// For operations in progress, it might indicate the current cost of the operation (if supported).
#[prost(message, optional, tag = "7")]
pub cost_info: ::core::option::Option<super::CostInfo>,
}
}
Loading

0 comments on commit 9fad323

Please sign in to comment.