Skip to content

Commit

Permalink
feat: refactor list_tables
Browse files Browse the repository at this point in the history
  • Loading branch information
v3g42 committed Oct 7, 2023
1 parent d53a131 commit 2ebba9b
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 33 deletions.
3 changes: 2 additions & 1 deletion dozer-cli/src/live/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ use dozer_types::{
},
contract::{
contract_service_server::{ContractService, ContractServiceServer},
CommonRequest, DotResponse, ProtoResponse, SchemasResponse, SourcesRequest,
CommonRequest, DotResponse, ProtoResponse, SourcesRequest,
},
live::{
code_service_server::{CodeService, CodeServiceServer},
ConnectResponse, Label, Labels, RunRequest,
},
types::SchemasResponse,
},
log::info,
};
Expand Down
3 changes: 2 additions & 1 deletion dozer-cli/src/live/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ use dozer_sql::builder::statement_to_pipeline;
use dozer_tracing::{Labels, LabelsAndProgress};
use dozer_types::{
grpc_types::{
contract::{DotResponse, ProtoResponse, SchemasResponse},
contract::{DotResponse, ProtoResponse},
live::{BuildResponse, BuildStatus, ConnectResponse, LiveApp, LiveResponse, RunRequest},
types::SchemasResponse,
},
log::info,
models::{
Expand Down
9 changes: 1 addition & 8 deletions dozer-cli/src/simple/build/contract/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use dozer_core::{
Direction,
},
};
use dozer_types::grpc_types::{contract::Schema, conversions::field_definition_to_grpc};
use dozer_types::grpc_types::{conversions::map_schema, types::Schema};

use crate::errors::BuildError;

Expand Down Expand Up @@ -242,13 +242,6 @@ impl Display for UiEdgeType {

type UiGraph = daggy::Dag<UiNodeType, UiEdgeType>;

fn map_schema(schema: dozer_types::types::Schema) -> Schema {
Schema {
primary_index: schema.primary_index.into_iter().map(|i| i as i32).collect(),
fields: field_definition_to_grpc(schema.fields),
}
}

fn remove_from_processor(graph: &UiGraph) -> UiGraph {
let mut output = UiGraph::new();

Expand Down
17 changes: 8 additions & 9 deletions dozer-types/protos/cloud.proto
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
syntax = "proto3";
package dozer.cloud;
import "types.proto";
import "cloud_types.proto";
import "cloud_notification.proto";
import "cloud_infastructure.proto";
import "google/protobuf/timestamp.proto";
import "google/protobuf/empty.proto";
service DozerCloud {

rpc validate_connection(ConnectionRequest)
returns (ValidateConnectionResponse);
rpc create_connection(ConnectionRequest) returns (ConnectionResponse);
rpc get_connection(GetConnectionRequest) returns (ConnectionResponse);
rpc list_connections(GetAllConnectionRequest)
returns (GetAllConnectionResponse);
rpc get_tables(GetTablesRequest) returns (GetTablesResponse);
rpc list_tables(ListTablesRequest) returns (dozer.types.SchemasResponse);
rpc update_connection(UpdateConnectionRequest) returns (ConnectionResponse);

rpc list_applications(ListAppRequest) returns (ListAppResponse);
Expand Down Expand Up @@ -239,7 +238,7 @@ message ConnectionRequest {
message GetConnectionRequest {
string connection_id = 1;
}
message ValidateConnectionResponse { bool success = 1; }

message ConnectionResponse {
string id = 1;
string name = 2;
Expand All @@ -249,11 +248,11 @@ message Connection {
string name = 1;
string yaml_content = 3;
}
message GetTablesRequest { string connection_id = 2; }

message GetTablesResponse {
string connection_id = 1;
repeated TableInfo tables = 2;
message ListTablesRequest {
oneof criteria {
string connection_id = 1;
string yaml = 2;
}
}

message GetAllConnectionRequest {
Expand Down
17 changes: 3 additions & 14 deletions dozer-types/protos/contract.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ package dozer.contract;
import "types.proto";

service ContractService {
rpc Sources(SourcesRequest) returns (SchemasResponse);
rpc Endpoints(CommonRequest) returns (SchemasResponse);
rpc Sources(SourcesRequest) returns (dozer.types.SchemasResponse);
rpc Endpoints(CommonRequest) returns (dozer.types.SchemasResponse);
rpc GenerateDot(CommonRequest) returns (DotResponse);
rpc GetGraphSchemas(CommonRequest) returns (SchemasResponse);
rpc GetGraphSchemas(CommonRequest) returns (dozer.types.SchemasResponse);
rpc GetProtos(CommonRequest) returns (ProtoResponse);
}

Expand All @@ -28,17 +28,6 @@ message CommonRequest {
optional CloudVersionId cloud_id = 1;
}

message SchemasResponse {
map<string, Schema> schemas = 1;
}

message Schema {
// The list of indexes of the keys that are used as the primary index.
repeated int32 primary_index = 1;
// The list of field definitions.
repeated dozer.types.FieldDefinition fields = 2;
}

message DotResponse {
string dot = 1;
}
Expand Down
10 changes: 10 additions & 0 deletions dozer-types/protos/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,13 @@ message Value {
google.protobuf.Value json_value = 14; // JSON type.
};
}
message SchemasResponse {
map<string, Schema> schemas = 1;
}

message Schema {
// The list of indexes of the keys that are used as the primary index.
repeated int32 primary_index = 1;
// The list of field definitions.
repeated FieldDefinition fields = 2;
}
6 changes: 6 additions & 0 deletions dozer-types/src/grpc_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,10 @@ pub mod conversions {
FieldType::Duration => Type::Duration,
}
}
pub fn map_schema(schema: crate::types::Schema) -> crate::grpc_types::types::Schema {
crate::grpc_types::types::Schema {
primary_index: schema.primary_index.into_iter().map(|i| i as i32).collect(),
fields: field_definition_to_grpc(schema.fields),
}
}
}

0 comments on commit 2ebba9b

Please sign in to comment.