mirror of
https://codeberg.org/JasterV/granc.git
synced 2026-04-26 18:40:05 +00:00
This pull request introduces dynamic server reflection support to the `granc` CLI, allowing users to call gRPC services without needing a local descriptor file. The changes include new reflection client logic, CLI and core refactoring, an updated README, and build system improvements. **Server Reflection Support:** * Added a copy of the official `grpc.reflection.v1` proto file to `granc/proto/reflection.proto` to enable dynamic schema fetching from servers that support reflection. * Implemented logic in the core orchestration layer (`granc/src/core.rs`) to resolve service descriptors either from a local file or dynamically via server reflection. The CLI now works seamlessly whether or not a `--proto-set` is provided. **CLI and Core Refactoring:** * Moved the CLI definition to `granc/src/cli.rs`, now supporting an optional `--proto-set`, improved endpoint parsing, and conversion to the new internal core `Input` type. * Refactored the core logic into `granc/src/core.rs` and implemented a more structured input, output and error handling, now making the core logic unit testable. **Documentation and Usability:** * Updated `granc/README.md` to document the new server reflection feature, clarify usage with and without descriptor files, and revise CLI argument documentation and examples. [[1]](diffhunk://#diff-0648f0ef1e166ae07f3ab14aa268c3497c2e3a49ffa189f85f9dfb88493f2440R17-L19) [[2]](diffhunk://#diff-0648f0ef1e166ae07f3ab14aa268c3497c2e3a49ffa189f85f9dfb88493f2440L34-R44) [[3]](diffhunk://#diff-0648f0ef1e166ae07f3ab14aa268c3497c2e3a49ffa189f85f9dfb88493f2440L57-R101) [[4]](diffhunk://#diff-0648f0ef1e166ae07f3ab14aa268c3497c2e3a49ffa189f85f9dfb88493f2440L97) [[5]](diffhunk://#diff-0648f0ef1e166ae07f3ab14aa268c3497c2e3a49ffa189f85f9dfb88493f2440L106-R125) **Generating a reflection service:** * Updated `granc/Cargo.toml` to add a `gen-proto` feature, declare both binaries (`granc` and `generate_reflection_service`), and manage dependencies for reflection and proto generation. * Improved `Makefile.toml` with new tasks for generating the reflection service client.
55 lines
1.3 KiB
TOML
55 lines
1.3 KiB
TOML
[config]
|
|
default_to_workspace = false
|
|
skip_core_tasks = true
|
|
|
|
[tasks.ci]
|
|
description = "CI task: Runs checks without modifying files"
|
|
dependencies = ["fmt-check", "clippy", "test"]
|
|
|
|
[tasks.run]
|
|
description = "Runs the CLI tool with dynamic arguments"
|
|
command = "cargo"
|
|
# Added '-p granc' to explicitly target the CLI binary in the workspace
|
|
args = ["run", "-p", "granc", "${@}"]
|
|
|
|
[tasks.test]
|
|
description = "Runs tests for the granc crate only"
|
|
command = "cargo"
|
|
# Added '-p granc' to strictly run integration/unit tests for the CLI
|
|
args = ["nextest", "run", "--no-fail-fast", "-p", "granc"]
|
|
|
|
[tasks.fmt]
|
|
description = "Formats all source files"
|
|
command = "cargo"
|
|
args = ["fmt", "--all"]
|
|
|
|
[tasks.fmt-check]
|
|
description = "Checks formatting without modifying files (fails if unformatted)"
|
|
command = "cargo"
|
|
args = ["fmt", "--all", "--", "--check"]
|
|
|
|
[tasks.clippy]
|
|
description = "Runs Clippy lints on the workspace"
|
|
command = "cargo"
|
|
# Added '--workspace' to lint both crates
|
|
args = [
|
|
"clippy",
|
|
"--workspace",
|
|
"--all-targets",
|
|
"--all-features",
|
|
"--",
|
|
"-D",
|
|
"warnings",
|
|
]
|
|
|
|
|
|
[tasks.generate_reflection_service]
|
|
description = "Runs a binary that generates a reflection service client from the reflection proto definitions"
|
|
command = "cargo"
|
|
args = [
|
|
"run",
|
|
"--bin",
|
|
"generate_reflection_service",
|
|
"--features",
|
|
"gen-proto",
|
|
]
|