Crates.io | grpc-ease |
lib.rs | grpc-ease |
version | 0.1.1 |
source | src |
created_at | 2024-05-25 19:55:55.754314 |
updated_at | 2024-05-25 20:03:00.379554 |
description | wrappers and helper structures for working with gRPC in Rust using the Tonic library |
homepage | https://arteiii.github.io |
repository | https://github.com/Arteiii/grpc-ease |
max_upload_size | |
id | 1252172 |
size | 34,743 |
a Rust crate that provides convenient wrappers and helper structures for working with gRPC in Rust using the Tonic library
This crate aims to simplify the process of interacting with gRPC services and parsing protocol buffer files.
Add this to your Cargo.toml:
[dependencies]
tonic-helper = "0.1.0"
tonic = "0.11"
tokio = { version = "1", features = ["full"] }
tracing = "0.1"
To list all gRPC services and their RPC methods from a server:
use grpc_ease::reflection::ReflectionClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let endpoint = "http://[::1]:4444";
let mut reflection_client = ReflectionClient::new(endpoint.to_string()).await?;
let services = reflection_client.list_services().await?;
for service in services {
println!("Service: {}", service.service);
println!("Package: {}", service.package);
for method in service.methods {
println!(" RPC Method: {}", method.name);
}
}
Ok(())
}
The GrpcReflectionClient
struct provides methods to interact with the gRPC reflection API.
list_services()
: Retrieves a list of services and their RPC methods.This project is licensed under the Apache License 2.0. See the LICENSE file for details.