大道至简,简即是繁
- 个人网站: https://colobu.com
- 最好的Go微服务框架: https://rpcx.io
- rpcx官方博客: https://blog.rpcx.io
rpcx microservice framework in Rust
Home Page: https://rpcx.io
License: Apache License 2.0
大道至简,简即是繁
rpcx_client 工程 -> src -> client.rs -> 93行
if self.opt.write_timeout.as_millis() > 0 {
stream.set_write_timeout(Some(self.opt.read_timeout))?;
}
这个写错了,将read_timeout设置到 write上
有计划支持async/await吗?
tokio升级到0.2?或者是支持smol或async-std?
我想注册
register_func!(
rpc_server,
RPC_PS_Path,
RPC_PS_Write,
write,
"".to_owned(),
WriteRequest,
WriteResponse
);
如果方法绑定在对象上 如
struct AAA{
}
impl AAA{
pub fn write(req) -> rep {}
}
register_func!(
rpc_server,
RPC_PS_Path,
RPC_PS_Write,
AAA.write,
"".to_owned(),
WriteRequest,
WriteResponse
);
不行的。
然后我用闭包
let write = |x: WriteRequest| -> WriteResponse {
let rep: WriteResponse = Default::default();
rep
};
register_func!(
rpc_server,
RPC_PS_Path,
RPC_PS_Write,
write,
"".to_owned(),
WriteRequest,
WriteResponse
);
还是不工作,这个问题该如何处理呀?谢谢
根据 Server::start
的函数签名:
pub fn start(&mut self) -> Result<()>
可以看到这里使用的是可变借用。该函数一旦执行将一直阻塞,直到 listen 用 fd 被关闭。
而这个 fd 只会在 Server::close
函数中被关闭,以下是它的函数签名:
pub fn close(&self)
可以看到这里有一个不可变借用。
由于 Rust 语言限制同一个变量的可变借用和不可变借用不能同时存在,因此在调用 start 函数之后,无法再调用 close 函数将其关闭。
请问有无优雅的方式来将正在监听的 RPC Server 关闭?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.