1b8483b92SLucio Franco 2d7484e35SLucio Franco 3d7484e35SLucio FrancoA rust implementation of [gRPC], a high performance, open source, general 4d7484e35SLucio FrancoRPC framework that puts mobile and HTTP/2 first. 5d7484e35SLucio Franco 602487becSLucio Franco[`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. 702487becSLucio Franco 85c4a2304SLucio Franco[](https://crates.io/crates/tonic) 96ab906d0SLucio Franco[](https://docs.rs/tonic) 105c4a2304SLucio Franco[](LICENSE) 115c4a2304SLucio Franco 125c4a2304SLucio Franco 134c8cf366Stottoto[Examples] | [Website] | [Docs] | [Chat][discord] 1402487becSLucio Franco 1502487becSLucio Franco## Overview 1602487becSLucio Franco 17d13a7b36SBradyBromley[`tonic`] is composed of three main components: the generic gRPC implementation, the high performance HTTP/2 1802487becSLucio Francoimplementation and the codegen powered by [`prost`]. The generic implementation can support any HTTP/2 19d13a7b36SBradyBromleyimplementation and any encoding via a set of generic traits. The HTTP/2 implementation is based on [`hyper`], 20d13a7b36SBradyBromleya fast HTTP/1.1 and HTTP/2 client and server built on top of the robust [`tokio`] stack. The codegen 2102487becSLucio Francocontains the tools to build clients and servers from [`protobuf`] definitions. 2202487becSLucio Franco 2363770cdcSLucio Franco## Features 2402487becSLucio Franco 2502487becSLucio Franco- Bi-directional streaming 2602487becSLucio Franco- High performance async io 2702487becSLucio Franco- Interoperability 2885060500SJames Nugent- TLS backed by [`rustls`] 2902487becSLucio Franco- Load balancing 3002487becSLucio Franco- Custom metadata 3102487becSLucio Franco- Authentication 32da92dbf8SJames Nugent- Health Checking 3302487becSLucio Franco 3402487becSLucio Franco## Getting Started 3502487becSLucio Franco 36*e508815bStottoto- The [`helloworld`][helloworld-tutorial] tutorial provides a basic example of using `tonic`, perfect for first time users! 37*e508815bStottoto- The [`routeguide`][routeguide-tutorial] tutorial provides a complete example of using `tonic` and all its features. 38*e508815bStottoto 39d9a481baSLucio FrancoExamples can be found in [`examples`] and for more complex scenarios [`interop`] 4002487becSLucio Francomay be a good resource as it shows examples of many of the gRPC features. 4102487becSLucio Franco 42e02e814cSLucio Franco### Rust Version 43a9f79925SLucio Franco 44f0156d4eStottoto`tonic`'s MSRV is `1.75`. 45a9f79925SLucio Franco 46fb840583SOpisthoteuthis agassizii### Dependencies 47fb840583SOpisthoteuthis agassizii 484c8cf366Stottoto[`tonic-build`] uses `protoc` [Protocol Buffers compiler] in some APIs which compile Protocol Buffers resource files such as [`tonic_build::compile_protos()`]. 49fb840583SOpisthoteuthis agassizii 504c8cf366Stottoto[Protocol Buffers compiler]: https://protobuf.dev/downloads/ 514c8cf366Stottoto[`tonic_build::compile_protos()`]: https://docs.rs/tonic-build/latest/tonic_build/fn.compile_protos.html 523a542709SGian Marco Gherardi 5302487becSLucio Franco## Getting Help 5402487becSLucio Franco 5502487becSLucio FrancoFirst, see if the answer to your question can be found in the API documentation. 5602487becSLucio FrancoIf the answer is not there, there is an active community in 574c8cf366Stottotothe [Tonic Discord channel][discord]. We would be happy to try to answer your 58d13a7b36SBradyBromleyquestion. If that doesn't work, try opening an [issue] with the question. 5902487becSLucio Franco 604c8cf366Stottoto[issue]: https://github.com/hyperium/tonic/issues/new/choose 6102487becSLucio Franco 6202487becSLucio Franco## Project Layout 6302487becSLucio Franco 644c8cf366Stottoto- [`tonic`]: Generic gRPC and HTTP/2 client/server implementation. 654c8cf366Stottoto- [`tonic-build`]: [`prost`] based service codegen. 664c8cf366Stottoto- [`tonic-types`]: [`prost`] based grpc utility types including support for gRPC Well Known Types. 674c8cf366Stottoto- [`tonic-health`]: Implementation of the standard [gRPC health checking service][healthcheck]. 684c8cf366Stottoto Also serves as an example of both unary and response streaming. 694c8cf366Stottoto- [`tonic-reflection`]: A tonic based gRPC reflection implementation. 704c8cf366Stottoto- [`examples`]: Example gRPC implementations showing off tls, load balancing and bi-directional streaming. 714c8cf366Stottoto- [`interop`]: Interop tests implementation. 7202487becSLucio Franco 7302487becSLucio Franco## Contributing 7402487becSLucio Franco 7502487becSLucio Franco:balloon: Thanks for your help improving the project! We are so happy to have 766ab906d0SLucio Francoyou! We have a [contributing guide][guide] to help you get involved in the Tonic 7702487becSLucio Francoproject. 7802487becSLucio Franco 7902487becSLucio Franco[guide]: CONTRIBUTING.md 8002487becSLucio Franco 8102487becSLucio Franco## License 8202487becSLucio Franco 8302487becSLucio FrancoThis project is licensed under the [MIT license](LICENSE). 8402487becSLucio Franco 8502487becSLucio Franco### Contribution 8602487becSLucio Franco 8702487becSLucio FrancoUnless you explicitly state otherwise, any contribution intentionally submitted 886ab906d0SLucio Francofor inclusion in Tonic by you, shall be licensed as MIT, without any additional 8902487becSLucio Francoterms or conditions. 9002487becSLucio Franco 9102487becSLucio Franco 92d7484e35SLucio Franco[gRPC]: https://grpc.io 934c8cf366Stottoto[`tonic`]: ./tonic 944c8cf366Stottoto[`tonic-build`]: ./tonic-build 954c8cf366Stottoto[`tonic-types`]: ./tonic-types 964c8cf366Stottoto[`tonic-health`]: ./tonic-health 974c8cf366Stottoto[`tonic-reflection`]: ./tonic-reflection 984c8cf366Stottoto[`examples`]: ./examples 994c8cf366Stottoto[`interop`]: ./interop 10002487becSLucio Franco[`tokio`]: https://github.com/tokio-rs/tokio 10102487becSLucio Franco[`hyper`]: https://github.com/hyperium/hyper 102b30b1a1eSNicholas Connor[`prost`]: https://github.com/tokio-rs/prost 1034c8cf366Stottoto[`protobuf`]: https://protobuf.dev/ 104b30b1a1eSNicholas Connor[`rustls`]: https://github.com/rustls/rustls 105bab1d5d2SLucio Franco[`interop`]: https://github.com/hyperium/tonic/tree/master/interop 106d9a481baSLucio Franco[Examples]: https://github.com/hyperium/tonic/tree/master/examples 107bee8acd8SLucio Franco[Website]: https://github.com/hyperium/tonic 10802487becSLucio Franco[Docs]: https://docs.rs/tonic 1094c8cf366Stottoto[discord]: https://discord.gg/6yGkFeN 110d9a481baSLucio Franco[routeguide-tutorial]: https://github.com/hyperium/tonic/blob/master/examples/routeguide-tutorial.md 111d9a481baSLucio Franco[helloworld-tutorial]: https://github.com/hyperium/tonic/blob/master/examples/helloworld-tutorial.md 1124c8cf366Stottoto[healthcheck]: https://grpc.io/docs/guides/health-checking/ 113