1![](https://github.com/hyperium/tonic/raw/master/.github/assets/tonic-banner.svg?sanitize=true)
2
3A rust implementation of [gRPC], a high performance, open source, general
4RPC framework that puts mobile and HTTP/2 first.
5
6[`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.
7
8[![Crates.io](https://img.shields.io/crates/v/tonic)](https://crates.io/crates/tonic)
9[![Documentation](https://docs.rs/tonic/badge.svg)](https://docs.rs/tonic)
10[![Crates.io](https://img.shields.io/crates/l/tonic)](LICENSE)
11
12
13[Examples] | [Website] | [Docs] | [Chat]
14
15## Overview
16
17[`tonic`] is composed of three main components: the generic gRPC implementation, the high performance HTTP/2
18implementation and the codegen powered by [`prost`]. The generic implementation can support any HTTP/2
19implementation and any encoding via a set of generic traits. The HTTP/2 implementation is based on [`hyper`],
20a fast HTTP/1.1 and HTTP/2 client and server built on top of the robust [`tokio`] stack. The codegen
21contains the tools to build clients and servers from [`protobuf`] definitions.
22
23## Features
24
25- Bi-directional streaming
26- High performance async io
27- Interoperability
28- TLS backed by [`rustls`]
29- Load balancing
30- Custom metadata
31- Authentication
32- Health Checking
33
34## Getting Started
35
36Examples can be found in [`examples`] and for more complex scenarios [`interop`]
37may be a good resource as it shows examples of many of the gRPC features.
38
39If you're using [rust-analyzer] we recommend you set `"rust-analyzer.cargo.buildScripts.enable": true` to correctly load
40the generated code.
41
42For IntelliJ IDEA users, please refer to [this](https://github.com/intellij-rust/intellij-rust/pull/8056) and enable
43`org.rust.cargo.evaluate.build.scripts`
44[experimental feature](https://plugins.jetbrains.com/plugin/8182-rust/docs/rust-faq.html#experimental-features).
45
46### Rust Version
47
48`tonic`'s MSRV is `1.70`.
49
50```bash
51$ rustup update
52$ cargo build
53```
54
55### Dependencies
56
57In order to build `tonic` >= 0.8.0, you need the `protoc` Protocol Buffers compiler, along with Protocol Buffers resource files.
58
59#### Ubuntu
60
61```bash
62sudo apt update && sudo apt upgrade -y
63sudo apt install -y protobuf-compiler libprotobuf-dev
64```
65
66#### Alpine Linux
67
68```sh
69sudo apk add protoc protobuf-dev
70```
71
72#### macOS
73
74Assuming [Homebrew](https://brew.sh/) is already installed. (If not, see instructions for installing Homebrew on [the Homebrew website](https://brew.sh/).)
75
76```zsh
77brew install protobuf
78```
79
80#### Windows
81
82- Download the latest version of `protoc-xx.y-win64.zip` from [HERE](https://github.com/protocolbuffers/protobuf/releases/latest)
83- Extract the file `bin\protoc.exe` and put it somewhere in the `PATH`
84- Verify installation by opening a command prompt and enter `protoc --version`
85
86### Tutorials
87
88- The [`helloworld`][helloworld-tutorial] tutorial provides a basic example of using `tonic`, perfect for first time users!
89- The [`routeguide`][routeguide-tutorial] tutorial provides a complete example of using `tonic` and all its
90features.
91
92## Getting Help
93
94First, see if the answer to your question can be found in the API documentation.
95If the answer is not there, there is an active community in
96the [Tonic Discord channel][chat]. We would be happy to try to answer your
97question. If that doesn't work, try opening an [issue] with the question.
98
99[chat]: https://discord.gg/6yGkFeN
100[issue]: https://github.com/hyperium/tonic/issues/new
101
102## Project Layout
103
104- [`tonic`](https://github.com/hyperium/tonic/tree/master/tonic): Generic gRPC and HTTP/2 client/server
105implementation.
106- [`tonic-build`](https://github.com/hyperium/tonic/tree/master/tonic-build): [`prost`] based service codegen.
107- [`tonic-types`](https://github.com/hyperium/tonic/tree/master/tonic-types): [`prost`] based grpc utility types
108  including support for gRPC Well Known Types.
109- [`tonic-health`](https://github.com/hyperium/tonic/tree/master/tonic-health): Implementation of the standard [gRPC
110health checking service][healthcheck]. Also serves as an example of both unary and response streaming.
111- [`tonic-reflection`](https://github.com/hyperium/tonic/tree/master/tonic-reflection): A tonic based gRPC
112reflection implementation.
113- [`examples`](https://github.com/hyperium/tonic/tree/master/examples): Example gRPC implementations showing off
114tls, load balancing and bi-directional streaming.
115- [`interop`](https://github.com/hyperium/tonic/tree/master/interop): Interop tests implementation.
116
117## Contributing
118
119:balloon: Thanks for your help improving the project! We are so happy to have
120you! We have a [contributing guide][guide] to help you get involved in the Tonic
121project.
122
123[guide]: CONTRIBUTING.md
124
125## License
126
127This project is licensed under the [MIT license](LICENSE).
128
129### Contribution
130
131Unless you explicitly state otherwise, any contribution intentionally submitted
132for inclusion in Tonic by you, shall be licensed as MIT, without any additional
133terms or conditions.
134
135
136[gRPC]: https://grpc.io
137[`tonic`]: https://github.com/hyperium/tonic
138[`tokio`]: https://github.com/tokio-rs/tokio
139[`hyper`]: https://github.com/hyperium/hyper
140[`prost`]: https://github.com/tokio-rs/prost
141[`protobuf`]: https://developers.google.com/protocol-buffers
142[`rustls`]: https://github.com/rustls/rustls
143[`examples`]: https://github.com/hyperium/tonic/tree/master/examples
144[`interop`]: https://github.com/hyperium/tonic/tree/master/interop
145[Examples]: https://github.com/hyperium/tonic/tree/master/examples
146[Website]: https://github.com/hyperium/tonic
147[Docs]: https://docs.rs/tonic
148[Chat]: https://discord.gg/6yGkFeN
149[routeguide-tutorial]: https://github.com/hyperium/tonic/blob/master/examples/routeguide-tutorial.md
150[helloworld-tutorial]: https://github.com/hyperium/tonic/blob/master/examples/helloworld-tutorial.md
151[healthcheck]: https://github.com/grpc/grpc/blob/master/doc/health-checking.md
152[rust-analyzer]: https://rust-analyzer.github.io
153