< 返回版块

Jancd 发表于 2019-10-03 21:02

Tags:rust,news

rust-lang 主仓库突破 10,0000 次 commit

ust-lang/rust

截至发稿,rust-lang/rust 主仓库为 10,0006 次commit!!!

k8s 的 rust 客户端

类似于 client-go 的客户端,可以用 Rust 来编写更高效的 Kubernetes 控制器!

在过去的几个月里,博主使用 Rust 中编写了很多的 kubernets 专用代码。尽管 Kubernetes 本身是用 Go 语言编写的,但我发现我通常可以用 Rust 编写更简洁、可读和稳定的 Kubernetes 代码。例如,我最近在 Rust 和 Go 中编写了功能相当的 CRD 控制器。Go 版本有 1700 多行代码,并装载了样板文件和自动生成的代码。而 Rust 版本只有127行!!!它更容易理解和调试…而且写起来绝对更快。博文原文请看:http://technosophos.com/2019/08/07/writing-a-kubernetes-controller-in-rust.html

GitHub 仓库地址:https://github.com/clux/kube-rs

了解更多请看 reddit 讨论

Tonic: gRPC 将支持 async/await

Tonic 是一个基于 http/2 的 gRpc 实现,专注于高性能、互操作性和灵活性。Tonic 这个库是为了提供对异步/等待的一流支持,并作为使用 Rust 编写的生产系统的核心构建块。

Tonic 的目标是提供更多开箱即用的工具。它已经支持许多特性,并计划支持更多特性!以下是功能列表:

  • 纯 rust 实现(openssl 例外)
  • 通过 tonic-interop 测试互操作性
  • 双向流
  • 自定义元数据
  • 功能齐全的 HTTP/2 客户端和基于 hyper 的服务器
  • 基于 openssl 或 rustls 支持的 TLS
  • 可靠性特性,如超时、速率限制、并发控制等
  • gRPC 拦截器
  • ... 还有更多,了解详情请点击
client 端示例:
let mut client = GreeterClient::connect("http://[::1]:50051")?;
let request = Request::new(HelloRequest {
    name: "hello".into(),
});
let response = client.say_hello(request).await?;
println!("RESPONSE={:?}", response);
server 端示例
#[tonic::async_trait]
impl Greeter for MyGreeter {
    async fn say_hello(&self, req: Request<HelloRequest>)
        -> Result<Response<HelloReply>, Status>
    {
        println!("Got a request: {:?}", req);
        let reply = HelloReply {
            message: "Zomg, it works!".into(),
        };
        Ok(Response::new(reply))
    }
}

micromath v0.4.0:快速、微型嵌入式的数学库

micromath

目前支持:powf, exp, log10, log2, log, ln, trunc, fract, copysign,了解更多请查看:https://crates.io/crates/micromath/0.4.0

folia:处理 FoLiA XML 格式的高性能Rust库

关键词:nlpxmltext-processing

这个库目前处于 alpha 阶段,它可能已经用于读取 FoLiA 文档和从头创建文档。注意,这个库还没有实现验证!您必须通过运行另一个 FoLiA 验证器来确保您的 FoLiA 文档是有效的,因为这个库还不能保证生成有效的 FoLiA。

使用示例,从文件中读取并查询所有单词:

extern crate folia;

use folia;

//load document from file
let doc = folia::Document::from_file(filename, folia::DocumentProperties::default()).expect("parsing folia");
//Build a query, here you can match on any attribute
let query = folia::Query::select().element(folia::Cmp::Is(folia::ElementType::Word));
//Turn the query into a specific selector
let selector = folia::Selector::from_query(&doc, &query);

//Run the selector
for word in doc.select(selector, folia::Recursion::Always) {
    //print the ID and the text
    println!("{}\t{}",
        word.id().or(Some("No-ID")),
        word.text(&folia::TextParameters::default())
    );
}

了解更多请点击查看


From 日报小组 @Jancd

日报订阅地址:

独立日报订阅地址:

社区学习交流平台订阅:

评论区

写评论

还没有评论

1 共 0 条评论, 1 页