grpc-rust README

The project's README from github.com/grpc/grpc-rust. As one markdown file: README.md.

A rust implementation of gRPC, a high performance, open source, general RPC framework that puts mobile and HTTP/2 first.

Note: tonic's master branch is currently preparing breaking changes. For the most recently released code, look to the 0.14.x branch.

tonic is a gRPC over HTTP/2 implementation focused on high performance, interoperability, and flexibility. This library was created to have first class support of async/await and to act as a core building block for production systems written in Rust.

Crates.io Documentation Crates.io

Examples | Website | Docs | Chat

Overview

tonic is composed of three main components: the generic gRPC implementation, the high performance HTTP/2 implementation and the codegen powered by prost. The generic implementation can support any HTTP/2 implementation and any encoding via a set of generic traits. The HTTP/2 implementation is based on hyper, a fast HTTP/1.1 and HTTP/2 client and server built on top of the robust tokio stack. The codegen contains the tools to build clients and servers from protobuf definitions.

Features

Getting Started

Examples can be found in examples and for more complex scenarios interop may be a good resource as it shows examples of many of the gRPC features.

Rust Version

tonic's MSRV is 1.88.

Dependencies

tonic-build uses protoc Protocol Buffers compiler in some APIs which compile Protocol Buffers resource files such as tonic_build::compile_protos().

Getting Help

First, see if the answer to your question can be found in the API documentation. If the answer is not there, there is an active community in the Tonic Discord channel. We would be happy to try to answer your question. If that doesn't work, try opening an issue with the question.

Project Layout

Contributing

:balloon: Thanks for your help improving the project! We are so happy to have you! We have a contributing guide to help you get involved in the Tonic project.

License

This project is licensed under the MIT license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Tonic by you, shall be licensed as MIT, without any additional terms or conditions.

grpc-rust (grpc/grpc-rust)

Searching Database…

12.5K ·GitHub
这是什么?tonic——一个用 Rust 原生实现的 gRPC 客户端和服务端库。它基于 HTTP/2 运行,对 async/await 有一等支持,是编写 Rust 生产系统的核心基础组件之一。
它是写代码时依赖的库,还是要部署运行的应用?它是一个库,不是部署用的应用。它主要由三部分组成:通用的 gRPC 实现、基于 hyper 和 tokio 的高速 HTTP/2 实现,以及由 prost 提供支持的代码生成,可以根据 protobuf 定义生成客户端和服务端代码。
该怎么上手使用它?先从 helloworld 教程开始——这是一个面向初次使用者的基础示例——然后再看 routeguide,它是一个覆盖全部功能的完整示例。examples 目录里还有 TLS、负载均衡和双向流式传输的示例。
除了 Rust,我还需要安装什么?需要 Rust 1.88 或更新版本(官方声明的最低支持版本 MSRV),另外还需要 protoc(Protocol Buffers 编译器),因为 tonic-build 的一些 API(比如 tonic_build::compile_protos())要用它来编译 .proto 文件。
master 分支现在可以直接用来开发吗?不太合适:master 分支目前正在准备不兼容的改动。如果想用最近正式发布的代码,README 指向的是 0.14.x 分支。
它开箱就支持哪些 gRPC 功能?支持双向流式传输、基于 rustls 的 TLS、负载均衡、自定义元数据、身份验证和健康检查,全部跑在高性能异步 I/O 上。它还提供一组通用 trait,可以运行在任何 HTTP/2 实现之上,并支持任意编码方式。
既然已经有现成的 gRPC 库,为什么还要做 tonic?README 里说明,创建它是为了提供对 async/await 的一等支持,并作为编写 Rust 生产系统的核心基础组件,把它的 gRPC 实现构建在 tokio 和 hyper 技术栈之上。
它能和其他语言写的 gRPC 服务通信吗?可以。互操作性是它明确的设计目标之一,仓库还附带了一套专门的互操作测试套件,覆盖许多 gRPC 功能,因此它符合标准规范,能与其他符合标准的 gRPC 实现配合工作。
tonic-health 和 tonic-reflection 提供了什么功能?tonic-health 实现了标准的 gRPC 健康检查服务(同时也作为一元调用和响应流式调用的示例),tonic-reflection 增加了 gRPC 反射功能,tonic-types 则提供 gRPC Well Known Types 的相关工具。
Creator
grpc
Size
83.6 MB
Stars
12.5K
Age
7y
Commits · 90 Days