Git Product home page Git Product logo

Comments (13)

tikue avatar tikue commented on May 5, 2024

I'll take a crack at this. It'll probably end up on the async branch, which will get merged into master soon (tm).

from tarpc.

tikue avatar tikue commented on May 5, 2024

To the async branch (tikue/async) I added Client::new(Stream), as well as ServeHandle::accept(Stream) where

enum Stream { 
    Tcp(TcpStream), 
    Pipe(PipeWriter, PipeReader),
}

Let me know if you're able to get it working with that. I haven't tested it at all yet.

from tarpc.

tikue avatar tikue commented on May 5, 2024

Added an example demonstrating the usage of pipes.

from tarpc.

sbstp avatar sbstp commented on May 5, 2024

Hey, thanks a lot for the quick reply. This looks good.

One thing I'm unsure about, is how to transform a ChildStdin into a PipeWriter.
For instance, the child process would try to connect to the master process in its main.

fn main() {
     let client = Client::connect((io::stdin(), io::stdout()));
}

But it might be impossible to do with mio. Looking quickly at the Stdin/Stdout structs, it doesn't look like they can be set non-blocking.

from tarpc.

tikue avatar tikue commented on May 5, 2024

I spent a bit of time trying to figure that out last night too. I think the best thing to do would be to file an issue on either the rust or mio repo. I'm kind of the middle man here unfortunately.

from tarpc.

tikue avatar tikue commented on May 5, 2024

@sbstp looks like mio added it a couple weeks ago.

from tarpc.

sbstp avatar sbstp commented on May 5, 2024

I've searched very briefly, and it doesn't look like there's an easy, cross platform way of configuring stdio to be unblocking. It behaves a lot like file I/O.

We could write a polyfill using background thread to simulate asynchronous I/O, or abandon the entire idea of using stdio.

from tarpc.

tikue avatar tikue commented on May 5, 2024

@sbstp what about mio's support of it that I just linked?

Edit: ah, it's probably only unix support.

from tarpc.

sbstp avatar sbstp commented on May 5, 2024

Looks like I didn't search properly. You can fnctl it like any other file descriptor. That fixes our issues then! Only need a new version of mio.

EDIT: It wouldn't work on Windows because the PipeWriter/PipeReader are only available on unix. It's not a problem for my own uses, but it might be a bother for some.

from tarpc.

tikue avatar tikue commented on May 5, 2024

@sbstp yeah, I just added #[cfg(unix)] to tarpc's pipe and unix socket support.

from tarpc.

tikue avatar tikue commented on May 5, 2024

This feature was lost in the tokio rewrite. I'm not sure how I feel about it now. I do like the simplicity of dealing strictly with TCP, but I realize that there's an opportunity here to be useful to a wider audience. I think I'll continue to leave this issue open, but I don't intend to implement it at this time unless there's significant demand.

from tarpc.

tikue avatar tikue commented on May 5, 2024

Should tarpc be generic over the transport layer (basically Io, or the new AsyncRead + AsyncWrite)? It seems worth considering, though I don't know if the hit to ergonomics is worth it. All clients and servers taking a type parameter seems rough. Maybe it's better to just extend StreamType to support a few more types of streams.

from tarpc.

tikue avatar tikue commented on May 5, 2024

Obsoleted by #199. tarpc is now transport-agnostic.

from tarpc.

Related Issues (20)

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.