multiple requests to the structure of a tables at once(batching)
This commit is contained in:
@@ -4,40 +4,45 @@ package komp_ac.table_structure;
|
||||
|
||||
import "common.proto";
|
||||
|
||||
// Introspects the physical PostgreSQL table for a given logical table
|
||||
// (defined in table_definitions) and returns its column structure.
|
||||
// Introspects the physical PostgreSQL tables for one or more logical tables
|
||||
// (defined in table_definitions) and returns their column structures.
|
||||
// The server validates that:
|
||||
// - The profile (schema) exists in `schemas`
|
||||
// - The table is defined for that profile in `table_definitions`
|
||||
// It then queries information_schema for the physical table and returns
|
||||
// normalized column metadata. If the physical table is missing despite
|
||||
// a definition, the response may contain an empty `columns` list.
|
||||
// - Every table is defined for that profile in `table_definitions`
|
||||
// It then queries information_schema for the physical tables and returns
|
||||
// normalized column metadata.
|
||||
service TableStructureService {
|
||||
// Return the physical column list (name, normalized data_type,
|
||||
// nullability, primary key flag) for a table in a profile.
|
||||
// nullability, primary key flag) for one or more tables in a profile.
|
||||
//
|
||||
// Behavior:
|
||||
// - NOT_FOUND if profile doesn't exist in `schemas`
|
||||
// - NOT_FOUND if table not defined for that profile in `table_definitions`
|
||||
// - NOT_FOUND if any table is not defined for that profile in `table_definitions`
|
||||
// - Queries information_schema.columns ordered by ordinal position
|
||||
// - Normalizes data_type text (details under TableColumn.data_type)
|
||||
// - Returns an empty list if the table is validated but has no visible
|
||||
// columns in information_schema (e.g., physical table missing)
|
||||
rpc GetTableStructure(GetTableStructureRequest) returns (TableStructureResponse);
|
||||
// - Returns an error if any validated table has no visible columns in
|
||||
// information_schema (e.g., physical table missing)
|
||||
rpc GetTableStructure(GetTableStructureRequest) returns (GetTableStructureResponse);
|
||||
}
|
||||
|
||||
// Request identifying the profile (schema) and table to inspect.
|
||||
// Request identifying the profile (schema) and tables to inspect.
|
||||
message GetTableStructureRequest {
|
||||
// Required. Profile (PostgreSQL schema) name. Must exist in `schemas`.
|
||||
string profile_name = 1;
|
||||
|
||||
// Required. Table name within the profile. Must exist in `table_definitions`
|
||||
// for the given profile. The physical table is then introspected via
|
||||
// information_schema.
|
||||
string table_name = 2;
|
||||
// Required. Table names within the profile. Each must exist in
|
||||
// `table_definitions` for the given profile. The physical tables are then
|
||||
// introspected via information_schema.
|
||||
repeated string table_names = 2;
|
||||
}
|
||||
|
||||
// Response with the ordered list of columns (by ordinal position).
|
||||
// Batched response keyed by table name.
|
||||
message GetTableStructureResponse {
|
||||
// Per-table physical column lists keyed by requested table name.
|
||||
map<string, TableStructureResponse> table_structures = 1;
|
||||
}
|
||||
|
||||
// Response with the ordered list of columns (by ordinal position) for one table.
|
||||
message TableStructureResponse {
|
||||
// Columns of the physical table, including system columns (id, deleted,
|
||||
// created_at), user-defined columns, and any foreign-key columns such as
|
||||
|
||||
Binary file not shown.
@@ -1,17 +1,27 @@
|
||||
// This file is @generated by prost-build.
|
||||
/// Request identifying the profile (schema) and table to inspect.
|
||||
/// Request identifying the profile (schema) and tables to inspect.
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct GetTableStructureRequest {
|
||||
/// Required. Profile (PostgreSQL schema) name. Must exist in `schemas`.
|
||||
#[prost(string, tag = "1")]
|
||||
pub profile_name: ::prost::alloc::string::String,
|
||||
/// Required. Table name within the profile. Must exist in `table_definitions`
|
||||
/// for the given profile. The physical table is then introspected via
|
||||
/// information_schema.
|
||||
#[prost(string, tag = "2")]
|
||||
pub table_name: ::prost::alloc::string::String,
|
||||
/// Required. Table names within the profile. Each must exist in
|
||||
/// `table_definitions` for the given profile. The physical tables are then
|
||||
/// introspected via information_schema.
|
||||
#[prost(string, repeated, tag = "2")]
|
||||
pub table_names: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
|
||||
}
|
||||
/// Response with the ordered list of columns (by ordinal position).
|
||||
/// Batched response keyed by table name.
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct GetTableStructureResponse {
|
||||
/// Per-table physical column lists keyed by requested table name.
|
||||
#[prost(map = "string, message", tag = "1")]
|
||||
pub table_structures: ::std::collections::HashMap<
|
||||
::prost::alloc::string::String,
|
||||
TableStructureResponse,
|
||||
>,
|
||||
}
|
||||
/// Response with the ordered list of columns (by ordinal position) for one table.
|
||||
#[derive(Clone, PartialEq, ::prost::Message)]
|
||||
pub struct TableStructureResponse {
|
||||
/// Columns of the physical table, including system columns (id, deleted,
|
||||
@@ -55,14 +65,13 @@ pub mod table_structure_service_client {
|
||||
)]
|
||||
use tonic::codegen::*;
|
||||
use tonic::codegen::http::Uri;
|
||||
/// Introspects the physical PostgreSQL table for a given logical table
|
||||
/// (defined in table_definitions) and returns its column structure.
|
||||
/// Introspects the physical PostgreSQL tables for one or more logical tables
|
||||
/// (defined in table_definitions) and returns their column structures.
|
||||
/// The server validates that:
|
||||
/// - The profile (schema) exists in `schemas`
|
||||
/// - The table is defined for that profile in `table_definitions`
|
||||
/// It then queries information_schema for the physical table and returns
|
||||
/// normalized column metadata. If the physical table is missing despite
|
||||
/// a definition, the response may contain an empty `columns` list.
|
||||
/// - Every table is defined for that profile in `table_definitions`
|
||||
/// It then queries information_schema for the physical tables and returns
|
||||
/// normalized column metadata.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct TableStructureServiceClient<T> {
|
||||
inner: tonic::client::Grpc<T>,
|
||||
@@ -144,20 +153,20 @@ pub mod table_structure_service_client {
|
||||
self
|
||||
}
|
||||
/// Return the physical column list (name, normalized data_type,
|
||||
/// nullability, primary key flag) for a table in a profile.
|
||||
/// nullability, primary key flag) for one or more tables in a profile.
|
||||
///
|
||||
/// Behavior:
|
||||
/// - NOT_FOUND if profile doesn't exist in `schemas`
|
||||
/// - NOT_FOUND if table not defined for that profile in `table_definitions`
|
||||
/// - NOT_FOUND if any table is not defined for that profile in `table_definitions`
|
||||
/// - Queries information_schema.columns ordered by ordinal position
|
||||
/// - Normalizes data_type text (details under TableColumn.data_type)
|
||||
/// - Returns an empty list if the table is validated but has no visible
|
||||
/// columns in information_schema (e.g., physical table missing)
|
||||
/// - Returns an error if any validated table has no visible columns in
|
||||
/// information_schema (e.g., physical table missing)
|
||||
pub async fn get_table_structure(
|
||||
&mut self,
|
||||
request: impl tonic::IntoRequest<super::GetTableStructureRequest>,
|
||||
) -> std::result::Result<
|
||||
tonic::Response<super::TableStructureResponse>,
|
||||
tonic::Response<super::GetTableStructureResponse>,
|
||||
tonic::Status,
|
||||
> {
|
||||
self.inner
|
||||
@@ -198,31 +207,30 @@ pub mod table_structure_service_server {
|
||||
#[async_trait]
|
||||
pub trait TableStructureService: std::marker::Send + std::marker::Sync + 'static {
|
||||
/// Return the physical column list (name, normalized data_type,
|
||||
/// nullability, primary key flag) for a table in a profile.
|
||||
/// nullability, primary key flag) for one or more tables in a profile.
|
||||
///
|
||||
/// Behavior:
|
||||
/// - NOT_FOUND if profile doesn't exist in `schemas`
|
||||
/// - NOT_FOUND if table not defined for that profile in `table_definitions`
|
||||
/// - NOT_FOUND if any table is not defined for that profile in `table_definitions`
|
||||
/// - Queries information_schema.columns ordered by ordinal position
|
||||
/// - Normalizes data_type text (details under TableColumn.data_type)
|
||||
/// - Returns an empty list if the table is validated but has no visible
|
||||
/// columns in information_schema (e.g., physical table missing)
|
||||
/// - Returns an error if any validated table has no visible columns in
|
||||
/// information_schema (e.g., physical table missing)
|
||||
async fn get_table_structure(
|
||||
&self,
|
||||
request: tonic::Request<super::GetTableStructureRequest>,
|
||||
) -> std::result::Result<
|
||||
tonic::Response<super::TableStructureResponse>,
|
||||
tonic::Response<super::GetTableStructureResponse>,
|
||||
tonic::Status,
|
||||
>;
|
||||
}
|
||||
/// Introspects the physical PostgreSQL table for a given logical table
|
||||
/// (defined in table_definitions) and returns its column structure.
|
||||
/// Introspects the physical PostgreSQL tables for one or more logical tables
|
||||
/// (defined in table_definitions) and returns their column structures.
|
||||
/// The server validates that:
|
||||
/// - The profile (schema) exists in `schemas`
|
||||
/// - The table is defined for that profile in `table_definitions`
|
||||
/// It then queries information_schema for the physical table and returns
|
||||
/// normalized column metadata. If the physical table is missing despite
|
||||
/// a definition, the response may contain an empty `columns` list.
|
||||
/// - Every table is defined for that profile in `table_definitions`
|
||||
/// It then queries information_schema for the physical tables and returns
|
||||
/// normalized column metadata.
|
||||
#[derive(Debug)]
|
||||
pub struct TableStructureServiceServer<T> {
|
||||
inner: Arc<T>,
|
||||
@@ -307,7 +315,7 @@ pub mod table_structure_service_server {
|
||||
T: TableStructureService,
|
||||
> tonic::server::UnaryService<super::GetTableStructureRequest>
|
||||
for GetTableStructureSvc<T> {
|
||||
type Response = super::TableStructureResponse;
|
||||
type Response = super::GetTableStructureResponse;
|
||||
type Future = BoxFuture<
|
||||
tonic::Response<Self::Response>,
|
||||
tonic::Status,
|
||||
|
||||
Reference in New Issue
Block a user