Giter Site home page Giter Site logo

Comments (7)

aturon avatar aturon commented on May 8, 2024

There's a lot to think about here, but one thing that strikes me is: if we do find a good solution to this problem, it should be possible to introduce it without too much disruption, because existing Service implementations should be trivially transformable to the CPS'ed version. (Could do this via a blanket impl etc). Does that seem right? If so, I think it eliminates any urgency here.

from tower.

cramertj avatar cramertj commented on May 8, 2024

@aturon Yep, it'd be easy to wrap the current Service::call in a res.send(Service::call(req)). The blanket impl only makes sense in that direction, though, so middleware based around Service wouldn't be trivially compatible with NewService.

from tower.

seanmonstar avatar seanmonstar commented on May 8, 2024

Passing a Sink to as responder may be a separate topic from borrowing (or maybe its the only kind of borrowing you'd want?), but I'll comment about it specifically: the idea of Service is to serve RPC, where you have a single response for a request. A Sink implies being able to to send multiple items back. I suppose an item could implement Sink and only be allowed to send a single item, but then we've moved that constraint from compile-time to run-time.

from tower.

aturon avatar aturon commented on May 8, 2024

@seanmonstar For HTTP, think about response bodies, where you might produce the body in a series of chunks -- much like the BufStream trait in tower-web.

from tower.

seanmonstar avatar seanmonstar commented on May 8, 2024

@aturon I don't quite see the connection there. Do you mean if it were Sink<ResOrBuf<B>> with enum ResOrBuf<B> { Res(Response<()>), Buf(B), }?

from tower.

cramertj avatar cramertj commented on May 8, 2024

@seanmonstar Good call-- Sink isn't exactly what you want-- it's really trait Send<T, E> { async fn send(self, T) -> Result<T, E>; } or something.

from tower.

carllerche avatar carllerche commented on May 8, 2024

I don't believe there currently are any actions to take from this issue, so I'm going to close it. Please let me know if this is an incorrect conclusion.

from tower.

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.