Skip to content

Using capnp-rpc client in multi-threaded tokio #558

@juchiast

Description

@juchiast

My setup is:

interface CommandContext {
    data @0 () -> (data: Data);
}

interface CommandFactory {
    init @0 (name: Text, nd: Data) -> (cmd: CommandTrait);

    allAvailables @1 () -> (availables: Data);
}

interface CommandTrait {
    run @0 (ctx: CommandContext, inputs: Data) -> (output: Data);
}

I have 1 or more CommandFactory clients, calling them to initialize commands on remote servers. because capnp-rpc clients are not Send, I cannot send the clients to another thread, the CommandFactory and CommandTrait clients all need to stay in the same thread, so either:

  • the entire app need to be rewritten using tokio LocalSet and current_thread tokio runtime
  • I have to keep all capnp-rpc types in a separate tokio runtime, and communicate with them via channels

This seems like a huge limitation, am I missing something? Is there any workaround?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions