grpc-ease

Crates.iogrpc-ease
lib.rsgrpc-ease
version0.1.1
sourcesrc
created_at2024-05-25 19:55:55.754314
updated_at2024-05-25 20:03:00.379554
descriptionwrappers and helper structures for working with gRPC in Rust using the Tonic library
homepagehttps://arteiii.github.io
repositoryhttps://github.com/Arteiii/grpc-ease
max_upload_size
id1252172
size34,743
Ben (Arteiii)

documentation

README

grpc ease

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.

Features

  • Easy retrieval and parsing of .proto files from servers.
  • Helper functions to list gRPC services and RPC methods.

Installation

Add this to your Cargo.toml:

[dependencies]
tonic-helper = "0.1.0"
tonic = "0.11"
tokio = { version = "1", features = ["full"] }
tracing = "0.1"

Usage

Listing Services and RPC Methods

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.

License

This project is licensed under the Apache License 2.0. See the LICENSE file for details.

Commit count: 5

cargo fmt