mirror of
https://codeberg.org/JasterV/granc.git
synced 2026-04-26 18:40:05 +00:00
This pull request introduces a significant internal refactor of the `granc` project, decoupling core dynamic gRPC client logic into a new reusable library crate (`granc-core`). It also improves project organization, updates documentation, and enhances workspace configuration. The main CLI functionality is now built atop this new core, making future maintenance and extensibility easier. **Project structure and workspace improvements:** - Created a new crate, `granc-core`, to encapsulate all core dynamic gRPC client logic, including schema resolution, dynamic request dispatch, and reflection support. This enables potential reuse outside the CLI and clarifies project boundaries. (`granc-core/Cargo.toml`, `granc-core/src/client.rs`, [[1]](diffhunk://#diff-dd6f7ed591a1bd2577444d0079c1f56851ef74e3b9df75a86ef4af76681435f6R1-R126) [[2]](diffhunk://#diff-ddab7585cf4c860c9922ed56471bccf5804da60f0ccb174158fd31b9b82457abR1-R46) [[3]](diffhunk://#diff-46d757daaa6737f1a6247142e8abff1cb5079109e641c447e8a9793ea1f063adR1-R186) - Updated workspace configuration in `Cargo.toml` to include `granc-core`, centralize dependency versions, and set workspace-wide package metadata for consistency. (`Cargo.toml`, [Cargo.tomlL2-R26](diffhunk://#diff-2e9d962a08321605940b5a657135052fbcef87b5e360662bb527c96d9a615542L2-R26)) - Adjusted `echo-service` and other crates to use workspace-wide settings for edition and authors. (`echo-service/Cargo.toml`, [echo-service/Cargo.tomlL3-R3](diffhunk://#diff-e74eb8a3bebf341a9bee1cdcd5cd3a50e15998db5a9df9eaf9e7aec341287b1eL3-R3)) **Documentation :** - Added a detailed `README.md` for both the main project and the new `granc-core` library, providing clear installation, usage, and architecture guidance for users and contributors. (`README.md`, `granc-core/README.md`, [[1]](diffhunk://#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5R1-R172) [[2]](diffhunk://#diff-dd6f7ed591a1bd2577444d0079c1f56851ef74e3b9df75a86ef4af76681435f6R1-R126) **Build and tooling updates:** - Updated `Makefile.toml` to use workspace-wide test runs and renamed tasks/binaries for consistency with the new crate layout. (`Makefile.toml`, [[1]](diffhunk://#diff-9375fd04332c86472d7be397ef09428cb86babd8826880a5835bd1d1c1bdbc08L18-R18) [[2]](diffhunk://#diff-9375fd04332c86472d7be397ef09428cb86babd8826880a5835bd1d1c1bdbc08L45-R50) --- **Key changes:** **1. Core library extraction and refactor** - Moved dynamic gRPC client logic (including `GrancClient`, request/response types, and reflection handling) into a new `granc-core` crate, decoupling it from the CLI and preparing for independent publishing. [[1]](diffhunk://#diff-ddab7585cf4c860c9922ed56471bccf5804da60f0ccb174158fd31b9b82457abR1-R46) [[2]](diffhunk://#diff-46d757daaa6737f1a6247142e8abff1cb5079109e641c447e8a9793ea1f063adR1-R186) **2. Workspace and dependency management** - Updated the root `Cargo.toml` to add `granc-core` as a workspace member, centralize dependency versions, and set workspace-wide metadata fields (authors, edition, license, etc.). - Adjusted `echo-service` and new crates to inherit workspace settings for consistency. **3. Documentation** - Updated and added comprehensive `README.md` files for both the main project and the new core library, with installation, usage, and architecture sections. [[1]](diffhunk://#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5R1-R172) [[2]](diffhunk://#diff-dd6f7ed591a1bd2577444d0079c1f56851ef74e3b9df75a86ef4af76681435f6R1-R126) - Introduced a `CHANGELOG.md` to document project history and recent changes. **4. Build and CI tooling** - Updated test and generation commands in `Makefile.toml` to reflect the new workspace structure and binary names. [[1]](diffhunk://#diff-9375fd04332c86472d7be397ef09428cb86babd8826880a5835bd1d1c1bdbc08L18-R18) [[2]](diffhunk://#diff-9375fd04332c86472d7be397ef09428cb86babd8826880a5835bd1d1c1bdbc08L45-R50) **5. Housekeeping** - Removed outdated or redundant files as part of the refactor. [[1]](diffhunk://#diff-06572a96a58dc510037d5efa622f9bec8519bc1beab13c9f251e97e657a9d4edL1) [[2]](diffhunk://#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5L1) This refactor lays the groundwork for improved maintainability, easier future development, and potential wider adoption of the dynamic gRPC client logic outside the CLI.
149 lines
5.9 KiB
Protocol Buffer
149 lines
5.9 KiB
Protocol Buffer
// This file has been copied from the original gRPC Authors.
|
|
//
|
|
// The Apache License, Version 2.0 is used in this project and applies
|
|
// to this file too.
|
|
//
|
|
// I explicitly state that I haven't written this file and the copyright
|
|
// belongs completely to the original authors.
|
|
//
|
|
// Copyright 2016 The gRPC Authors
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
// Service exported by server reflection. A more complete description of how
|
|
// server reflection works can be found at
|
|
// https://github.com/grpc/grpc/blob/master/doc/server-reflection.md
|
|
//
|
|
// The canonical version of this proto can be found at
|
|
// https://github.com/grpc/grpc-proto/blob/master/grpc/reflection/v1/reflection.proto
|
|
|
|
syntax = "proto3";
|
|
|
|
package grpc.reflection.v1;
|
|
|
|
service ServerReflection {
|
|
// The reflection service is structured as a bidirectional stream, ensuring
|
|
// all related requests go to a single server.
|
|
rpc ServerReflectionInfo(stream ServerReflectionRequest)
|
|
returns (stream ServerReflectionResponse);
|
|
}
|
|
|
|
// The message sent by the client when calling ServerReflectionInfo method.
|
|
message ServerReflectionRequest {
|
|
string host = 1;
|
|
// To use reflection service, the client should set one of the following
|
|
// fields in message_request. The server distinguishes requests by their
|
|
// defined field and then handles them using corresponding methods.
|
|
oneof message_request {
|
|
// Find a proto file by the file name.
|
|
string file_by_filename = 3;
|
|
|
|
// Find the proto file that declares the given fully-qualified symbol name.
|
|
// This field should be a fully-qualified symbol name
|
|
// (e.g. <package>.<service>[.<method>] or <package>.<type>).
|
|
string file_containing_symbol = 4;
|
|
|
|
// Find the proto file which defines an extension extending the given
|
|
// message type with the given field number.
|
|
ExtensionRequest file_containing_extension = 5;
|
|
|
|
// Finds the tag numbers used by all known extensions of the given message
|
|
// type, and appends them to ExtensionNumberResponse in an undefined order.
|
|
// Its corresponding method is best-effort: it's not guaranteed that the
|
|
// reflection service will implement this method, and it's not guaranteed
|
|
// that this method will provide all extensions. Returns
|
|
// StatusCode::UNIMPLEMENTED if it's not implemented.
|
|
// This field should be a fully-qualified type name. The format is
|
|
// <package>.<type>
|
|
string all_extension_numbers_of_type = 6;
|
|
|
|
// List the full names of registered services. The content will not be
|
|
// checked.
|
|
string list_services = 7;
|
|
}
|
|
}
|
|
|
|
// The type name and extension number sent by the client when requesting
|
|
// file_containing_extension.
|
|
message ExtensionRequest {
|
|
// Fully-qualified type name. The format should be <package>.<type>
|
|
string containing_type = 1;
|
|
int32 extension_number = 2;
|
|
}
|
|
|
|
// The message sent by the server to answer ServerReflectionInfo method.
|
|
message ServerReflectionResponse {
|
|
string valid_host = 1;
|
|
ServerReflectionRequest original_request = 2;
|
|
// The server sets one of the following fields according to the message_request
|
|
// in the request.
|
|
oneof message_response {
|
|
// This message is used to answer file_by_filename, file_containing_symbol,
|
|
// file_containing_extension requests with transitive dependencies.
|
|
// As the repeated label is not allowed in oneof fields, we use a
|
|
// FileDescriptorResponse message to encapsulate the repeated fields.
|
|
// The reflection service is allowed to avoid sending FileDescriptorProtos
|
|
// that were previously sent in response to earlier requests in the stream.
|
|
FileDescriptorResponse file_descriptor_response = 4;
|
|
|
|
// This message is used to answer all_extension_numbers_of_type requests.
|
|
ExtensionNumberResponse all_extension_numbers_response = 5;
|
|
|
|
// This message is used to answer list_services requests.
|
|
ListServiceResponse list_services_response = 6;
|
|
|
|
// This message is used when an error occurs.
|
|
ErrorResponse error_response = 7;
|
|
}
|
|
}
|
|
|
|
// Serialized FileDescriptorProto messages sent by the server answering
|
|
// a file_by_filename, file_containing_symbol, or file_containing_extension
|
|
// request.
|
|
message FileDescriptorResponse {
|
|
// Serialized FileDescriptorProto messages. We avoid taking a dependency on
|
|
// descriptor.proto, which uses proto2 only features, by making them opaque
|
|
// bytes instead.
|
|
repeated bytes file_descriptor_proto = 1;
|
|
}
|
|
|
|
// A list of extension numbers sent by the server answering
|
|
// all_extension_numbers_of_type request.
|
|
message ExtensionNumberResponse {
|
|
// Full name of the base type, including the package name. The format
|
|
// is <package>.<type>
|
|
string base_type_name = 1;
|
|
repeated int32 extension_number = 2;
|
|
}
|
|
|
|
// A list of ServiceResponse sent by the server answering list_services request.
|
|
message ListServiceResponse {
|
|
// The information of each service may be expanded in the future, so we use
|
|
// ServiceResponse message to encapsulate it.
|
|
repeated ServiceResponse service = 1;
|
|
}
|
|
|
|
// The information of a single service used by ListServiceResponse to answer
|
|
// list_services request.
|
|
message ServiceResponse {
|
|
// Full name of a registered service, including its package name. The format
|
|
// is <package>.<service>
|
|
string name = 1;
|
|
}
|
|
|
|
// The error code and error message sent by the server when an error occurs.
|
|
message ErrorResponse {
|
|
// This field uses the error codes defined in grpc::StatusCode.
|
|
int32 error_code = 1;
|
|
string error_message = 2;
|
|
}
|