apache / dubbo-rust

Apache Dubbo Rust implementation
https://dubbo.apache.org/
Apache License 2.0
274 stars 63 forks source link

example目录下的示例中的build.rs怎么才能运行生成src/greeter/server.rs等文件? #192

Open fengnex opened 5 months ago

fengnex commented 5 months ago

如题,示例文档没法用 example跑步起来。。。。。。。。。。。

对示例项目运行cargo build不会自动生成 `[package] name = "dubbo1" version = "0.1.0" edition = "2021"

See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[[bin]]

name = "greeter-server"

path = "src/greeter/server.rs"

[[bin]]

name = "greeter-client"

path = "src/greeter/client.rs"

[dependencies] http = "1.0.0" http-body = "1.0.0" futures-util = {version = "0.3", default-features = false} tokio = { version = "1.0", features = [ "rt-multi-thread", "time", "fs", "macros", "net", "signal"] } prost-derive = {version = "0.12.2", optional = true} prost = "0.12.2" async-trait = "0.1.56" tokio-stream = "0.1"

dubbo = "0.3.0" dubbo-config = "0.3.0"

[build-dependencies]

dubbo-build = "0.3.0"

dubbo-build = {git = "https://github.com/yang20150702/dubbo-rust.git"}` [build-dependencies]的上面2个选项都不行

fengnex commented 5 months ago

直接在github上下载的dubbo-rust-main目录下执行cargo build可以解决上面的问题。但问题是在dubbo-rust-main之外新建的项目,怎么通过才能对proto文件生产源码?这里主要是dubbo-build这个工具看起来没有起作用或无法自动运行----这个才是是上面的问题。

fengnex commented 5 months ago

基于dubbo-rust-main在一台机器上运行greeter示例的服务端和客户端,nacos在本地以standalone模式运行,但是client遇到了下面的错误,二者还是不能正常通信,请教怎么解决: INFO dubbo::triple::transport::connector::http_connector:84: host is ip address: "0.0.0.0" thread 'main' panicked at dubbo\src\triple\transport\connection.rs:104:50: calledResult::unwrap()on anErrvalue: hyper::Error(Connect, Os { code: 10049, kind: AddrNotAvailable, message: " 在其上下文中,该请求的地址无效。" }) note: run withRUST_BACKTRACE=1environment variable to display a backtrace

onewe commented 5 months ago

目前 还在完善中, 不好意思😬

fengnex commented 5 months ago

理解,期待早日迈向成熟,更新相关文档。 这个示例现在必须要有nacos才能启动,但启动nacos后还是有问题,很遗憾。 看来目前nacos还是应以java、go版本为主。

onewe commented 5 months ago

目前活跃的开发者不多, 所以进度比较缓慢. 感谢理解.

fengnex commented 5 months ago

看了一部分代码,能发展到现在必须说已经挺好了! 相信这个项目一定会越来越好! 因为rust的优点和dubbo3的一些良好特性,这个项目一定会前景广阔的!

yang20150702 commented 5 months ago

@fengnex example下的 echo 例子是可以正常运行,该example没有使用服务发现。你可以试一下这个例子 对于nacos的报错,我们需要本地复现一下

yang20150702 commented 5 months ago

直接在github上下载的dubbo-rust-main目录下执行cargo build可以解决上面的问题。但问题是在dubbo-rust-main之外新建的项目,怎么通过才能对proto文件生产源码?这里主要是dubbo-build这个工具看起来没有起作用或无法自动运行----这个才是是上面的问题。

建议您先熟悉一下 echo 例子。可以直接clone源代码,在本地运行example。 对于您的问题,我简单介绍一下使用dubbo-rust进行rpc服务开发流程:

  1. cargo new echo:创建 cargo package
  2. 新增目录 protos,添加定义好的proto文件
  3. 在包的根目录下,新增 build.rs,用来compile proto文件来生成对应的rust代码。注意:需要预先在本地安装 protoc
  4. 我们在echo和greeter中提供了两种方案来use proto对应的rust代码,具体可以看代码
  5. 先实现Server,然后实现Client

参考: https://doc.rust-lang.org/cargo/reference/build-scripts.html : build.rs文件会优先执行 https://github.com/protocolbuffers/protobuf#protobuf-compiler-installation

fengnex commented 5 months ago

@yang20150702 现在版本的greeter示例已经能正常编译了,需要用到nacos,greeter服务也能注册到nacos,但是greeter-client不能与greeter-server通信,错误信息是: dubbo::triple::transport::connector::http_connector:84: host is ip address: "0.0.0.0" thread 'main' panicked at dubbo\src\triple\transport\connection.rs:104:50: called Result::unwrap() on an Err value: hyper::Error(Connect, Os { code: 10049, kind: AddrNotAvailable, message: " 在其上下文中,该请求的地址无效。" }) note: run with RUST_BACKTRACE=1 environment variable to display a backtrace 不是你说的那些。

onewe commented 5 months ago

我直接在项目中运行 greeter 好像没有复现您说的问题, image 给我们一点时间, 我们正在完善, 抱歉.

fengnex commented 5 months ago

echo这个示例写的挺好的,验证通过。但是在Windows10上验证echo-tls时,echo-tls-server.exe和echo-tls-client.exe都能编译出来,把server.crt和ca.crt都添加到系统信任根证书中,echo-tls-server.exe提示server starting. addr: 127.0.0.1:8889,看起来运行正常,但是运行echo-tls-client.exe时报下面的错,请教该怎么解决: RoutesFutureInnerState::Future ' panicked at dubbo\src\registry\registry.rs:78:63: called Option::unwrap() on a None value registry extension load failed.

fengnex commented 5 months ago

@onewe 刚才重试了下,greeter示例能编译成功,服务端看起来能正常运行,但是运行客户端时报下面的错误,二者还是不能正常通信: INFO dubbo::triple::transport::connector::http_connector:84: host is ip address: "0.0.0.0" thread 'main' panicked at dubbo\src\triple\transport\connection.rs:104:50: called Result::unwrap() on an Err value: hyper::Error(Connect, Os { code: 10049, kind: AddrNotAvailable, message: "在其上下文中,该请求的地址 无效。" }) note: run with RUST_BACKTRACE=1 environment variable to display a backtrace 这个错误跟上一次的一样,而且二者的编译、运行环境不同,2个环境应该可以证明这个问题了。