Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nacos client for rust #8443

Closed
keqingyuan opened this issue May 23, 2022 · 7 comments
Closed

nacos client for rust #8443

keqingyuan opened this issue May 23, 2022 · 7 comments
Assignees
Labels
area/Client Related to Nacos Client SDK contribution welcome kind/feature type/feature

Comments

@keqingyuan
Copy link

nacos client for rust

@KomachiSion KomachiSion added kind/feature type/feature area/Client Related to Nacos Client SDK contribution welcome labels May 23, 2022
@li-xiao-shuang
Copy link
Collaborator

nacos client for rust

Do you have such a need?

@intfish123
Copy link

I has used nacos in production env. and there are some rust service need to regist in nacos.
But there are no sdk for rust.

@CherishCai
Copy link
Contributor

I would like to contribute to the Nacos Rust sdk; let's work on this project together.

Can I contribute CherishCai/nacos-sdk-rust to nacos-group first, and then find participants to improve it together?

@CherishCai
Copy link
Contributor

CherishCai commented Sep 15, 2022

Nacos sdk Rust

背景/动机

  1. Nacos 多语言生态可以扩充到 Rust,也受益于其他开源社区,例如 Dubbo-Rust(建设中),Sentinel-Rust 等中间件。
  2. Rust 生态在蓬勃发展,目前 issue 中有多次提及 Nacos 支持 Rust 客户端,所以能满足部分用户诉求。

故而,希望 Nacos 社区一同构建 Rust 版的客户端(2.x gRPC 交互),满足中间件及用户诉求的配置管理/服务发现能力。

详细说明

另一些背景资料:Dubbo-Rust(建设中)项目组的同学,构建了 Nacos 注册中心模块 Naming 的支持 sezi-yuan/nacos-sdk-rust,但已有多个月未维护且仅是 1.x 的逻辑,不符合 gRPC 主流交互方案。感谢此同学的贡献,提供了很多可以借鉴的实现参考。

而 Nacos 新构建的 Rust 客户端,完全可以抛弃历史包袱全新设计,仅支持 Nacos 2.x 的 gRPC 交互,提供配置管理/服务发现两大核心能力。

注:参考社区优秀 Rust sdk 项目,例如 opentelemetry-rust, skywalking-rust, sentinel-rust, dubbo-rust

功能拆解(根据最新 Java 客户端,调整/增加/逐步完善)

Config 配置管理模块

  • 客户端创建 api
  • 获取配置 api 与实现
  • 监听配置 api 与实现,List-Watch 机制,具备 list 兜底逻辑
  • 配置 Filter,提供配置解密默认实现;配置获取后,内存缓存,磁盘缓存均是原文,仅返回到用户时经过配置 Filter

Naming 服务注册模块

  • 客户端创建 api
  • 注册服务 api 与实现
  • 反注册服务 api 与实现
  • 批量注册服务 api 与实现
  • 获取服务 api 与实现
  • 订阅服务 api 与实现,List-Watch 机制,具备 list 兜底逻辑
  • 服务防推空,默认开启,TODO 可选关闭。

Common 通用能力

  • 创建参数,自定义传参 + ENV 环境变量读取,后者优先级高;ENV 统一前缀,例如 NACOS_CLIENT_CONFIG_* 于配置管理, NACOS_CLIENT_NAMING_* 于服务注册
  • 通用客户端请求交互,Request/Response 通用 gRPC 逻辑,提供给 Config/Naming
  • Auth 鉴权;账密登陆 username/password,TODO ak/sk
  • 通用日志,tracing::info!()
  • Monitor,opentelemetry
  • 数据落盘与加载(用于服务端宕机弱依赖)

主要依赖包

为主要功能的实现,将会引入以下依赖包。

  • serde-rs/serde 一个超高性能的通用序列化/反序列化框架,可以跟多种协议的库联合使用,实现统一编解码格式
  • serde-rs/json 快到上天的 JSON 库,也是 Rust 序列化 json 的事实标准
  • tikv/grpc-rs 一个 Rust 版的 gRPC 客户端和服务器端
  • tokio-rs/prost tokio 出品的 Protocol Buffers 工具,简单易用,文档详细
  • tokio-rs/tokio 最火的异步网络库,除了复杂上手难度高一些外,没有其它大的问题。同时 tokio 团队提供了多个非常优秀的 Rust 库,整个生态欣欣向荣,用户认可度很高
  • tokio-rs/tracing 强大的日志框架,同时还支持 OpenTelemetry 格式,无缝打通未来的监控

可能存在的问题

  • 社区同学对 Rust 不够熟悉,前期可能会以核心能力实现优先,很多代码不够规范化,逻辑非最优。

期望社区同学讨论和参与~

@CherishCai
Copy link
Contributor

@CherishCai
Copy link
Contributor

nacos-group/nacos-sdk-rust#7


发布了初版 nacos-sdk=0.1.1 ,Config 模块基本可用,欢迎社区同学贡献、修复和标准化 api

https://crates.io/crates/nacos-sdk

https://docs.rs/nacos-sdk/0.1.1/nacos_sdk/

@CherishCai
Copy link
Contributor

CherishCai commented Nov 26, 2022

发布了完善版 nacos-sdk=0.2.0 ,Config/Naming 功能均可用,同时包括登陆鉴权,配置解密插件均在这个版本提供。

https://crates.io/crates/nacos-sdk

https://docs.rs/nacos-sdk/0.2.0/nacos_sdk/

后续请到仓库 https://github.com/nacos-group/nacos-sdk-rust ,或许这个 issue 可以关闭啦。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/Client Related to Nacos Client SDK contribution welcome kind/feature type/feature
Projects
None yet
Development

No branches or pull requests

5 participants