Giter VIP home page Giter VIP logo

rpcx-rs's Issues

发现一个写错的地方

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上

关于register_func! 注册一个对象的方法有什么办法吗?

我想注册

    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
    );

还是不工作,这个问题该如何处理呀?谢谢

rpc server 优雅的关闭方式

根据 Server::start 的函数签名:

pub fn start(&mut self) -> Result<()>

可以看到这里使用的是可变借用。该函数一旦执行将一直阻塞,直到 listen 用 fd 被关闭。
而这个 fd 只会在 Server::close 函数中被关闭,以下是它的函数签名:

pub fn close(&self)

可以看到这里有一个不可变借用。

由于 Rust 语言限制同一个变量的可变借用和不可变借用不能同时存在,因此在调用 start 函数之后,无法再调用 close 函数将其关闭。
请问有无优雅的方式来将正在监听的 RPC Server 关闭?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.