Tonic: 0.1 has arrived!

栏目: IT技术 · 发布时间: 5年前

内容简介:Since the firstTonic was originally released as an alpha because a majority of the crates it depended on were also alphas.

tonic is a gRPC over HTTP/2 implementation focused on high performance, interoperability, and flexibility. It has been a few months since I originally released the 0.1.0-alpha.1 version. Since then there has been a ton of growth and improvements. We’ve seen 32 new contributors , two new guides , 8 more examples and 5 releases . Not only have we seen a lot of growth internally but we’ve also seen a large amount of adoption.

Changes

Since the first 0.1.0-alpha.1 release, Tonic made several ergonomic changes.

Upgrades EVERYWHERE

Tonic was originally released as an alpha because a majority of the crates it depended on were also alphas. 0.1 signifies that all our dependencies are as lean as possible. For instance: syn and quote are at 1.0, bytes is set to 0.5 and hyper is at 0.13 Thanks to all the maintainers for helping push out all these releases! Also, I would like to note that cargo-deny has been very helpful in ensuring that we have no duplicate dependencies!

Goodbye openssl, hello rustls

The build-in transport module no longer supports openssl . Instead, Tonic defaults to rustls , which should simplify building Tonic-based applications and libraries. However, I recognize that Tonic users might want to use a different TLS library, so Tonic supports customization via constructor client and constructor server .

Interceptors

Tonic also supports gRPC interceptors (non-gRPC ecosystems might refer to “interceptors” as “middleware”). Like the name suggests, interceptors allow clients and servers to intercept a request and perform an arbitrary action, like adding headers to sign a request or logging a request. See the example below:

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let channel = Endpoint::from_static("http://[::1]:50051")
        .connect()
        .await?;
    let mut client = GreeterClient::with_interceptor(channel, intercept);
   // snip
}
/// This function will get called on each outbound request. Returning a
/// `Status` here will cancel the request and have that status returned to
/// the client.
fn intercept(req: Request<()>) -> Result<Request<()>, Status> {
    println!("Intercepting request: {:?}", req);
    Ok(req)
}

One key thing to note here is that these interceptors are transport agnostic. They are pure gRPC, it does not matter where you get the request from, it could be via grpc-web or http2 .

More examples of this usage can be found here .

v0.1.0

I’d like to give a special shoutout to all those that helped the project grow by opening issues, trying Tonic out and opening PRs.

That said, I am super happy to finally release the 0.1 release of tonic . This is the first stepping stone in a great ecosystem built on top of tower . As always, there is a changelog and an issue tracker if you run into any issues. Please, feel welcome to also join us on discord if you need any help!

Back to posts


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

密码朋克

密码朋克

[澳] 朱利安·阿桑奇 / Gavroche / 中信出版社 / 2017-10 / 42.00元

互联网已经在世界各地掀起了革命,然而全面的打击也正在展开。随着整个社会向互联网迁移,大规模监控计划也正在向全球部署。我们的文明已经来到一个十字路口。道路的一边通往一个承诺“弱者要隐私,强 者要透明”的未来,而另一边则通往一个极权的互联网,在那里,全人类的权力被转移给不受问责的间谍机构综合体及其跨国公司盟友。 密码朋克是一群倡导大规模使用强密码术以保护我们的基本自由免遭攻击的活动家。维基解密的......一起来看看 《密码朋克》 这本书的介绍吧!

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

URL 编码/解码
URL 编码/解码

URL 编码/解码

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试