by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jul 01 19:01
    yaahc commented #461
  • Jul 01 18:58
    LucioFranco commented #461
  • Jun 30 04:50
    hlb8122 synchronize #396
  • Jun 30 04:32
    hlb8122 ready_for_review #396
  • Jun 30 04:20
    hlb8122 commented #396
  • Jun 30 04:03
    hlb8122 synchronize #396
  • Jun 30 04:03
    hlb8122 synchronize #396
  • Jun 30 03:33
    hlb8122 edited #396
  • Jun 30 03:28
    hlb8122 synchronize #396
  • Jun 28 15:06
    hlb8122 edited #396
  • Jun 28 15:06
    hlb8122 edited #396
  • Jun 28 14:53
    hlb8122 synchronize #396
  • Jun 28 14:30
    hlb8122 synchronize #396
  • Jun 28 13:49
    hlb8122 synchronize #396
  • Jun 27 01:15
    hlb8122 synchronize #396
  • Jun 26 23:30
    hlb8122 synchronize #396
  • Jun 26 14:34
    hlb8122 edited #396
  • Jun 26 12:27
    hlb8122 commented #396
  • Jun 24 22:29
    hawkw commented #462
  • Jun 24 22:28
    hawkw commented #462
Carl Lerche
@carllerche
@/all let's move to discord. There is a tower channel in here: https://discord.gg/XdPzyTZ
Lucio Franco
@LucioFranco
@tikue hey! I think we've finally found some good abstractions around tower etc, would love to chat tarpc etc ^ discord prob works the best if you're interested :)
Tim
@tikue
@LucioFranco neat! Would love to talk. I'm pretty swamped though so asynchronous communication is probably my only option this week
Lucio Franco
@LucioFranco
:+1: no worries just wanted to circle back
ill reach out next ish week
Carl Fredrik Samson
@cfsamson

I encounter a problem with #[derive(Response)]. If I'm not mistaken this should work fine:

#[derive(Response)]
struct StoreResult {
    saved: String,
}

But I get this error that I can't figure out the root cause of:

error[E0107]: wrong number of type arguments: expected 1, found 2
   --> src\webserver\server.rs:154:10
    |
154 | #[derive(Response)]
    |          ^^^^^^^^ unexpected type argument

Any ideas?

Using tower-web = "0.3.7" btw.
Nathan Ringo
@remexre
I've currently got a Sink<Request>+Stream<Either<Response, Update>>; is there a convenient way to wrap it to get a Service+Stream<Update>?
and/or is there a better way to structure my program to get the effect of a service that can handle requests, but also pushes information?
Jon Gjengset
@jonhoo
@remexre All tower discussion has moved to Discord :) Go say hi over in the tower channel at https://discord.gg/XdPzyTZ
Nathan Ringo
@remexre
oh, ok; the repo still has a "Chat on Gitter" badge
Jon Gjengset
@jonhoo
Ah, I'll flag that over there!
Richard Gomes
@frgomes

Hello chaps. This is my first post here. :-)
You can know me better at http://github.com/frgomes

I've done a proof of concept with tower-web this weekend and I'm satisfied. I really don't miss boilerplate I've never needed. :-) I find tower-web really simple to use on the server side. I didn't have any troubles writing unit tests either. However, I had difficulties writing integration tests. I couldn't get tower-web client to work and I've resorted to some alien client side http client which I would like to avoid, really.

So, I'd like to ask your help on this matter.
Do you guys have real life examples of code employing tower-web client side, please?
In particular, I'm interested on an end-to-end test which sends a custom struct as application/json and receives another custom struct as application/json.

Thanks a lot! :-)

Armin Ronacher
@mitsuhiko
i'm writing a blog post about back pressure at the moment and i'm looking at tower quite a bit about this
the service trait is pretty great because it has a poll_ready but it's obviously inherently racy
so at capacity you're likely going to get an error from both poll_ready (Pending) as well as that you need to handle the error from call because it will be at capacity again
i wonder if it was considered (and if it was, why it was rejected) to return a token from poll_ready that could be used to guarantee a reservation from poll to call
that would be useful for instance if a semaphore was used behind the scenes to limit concurrency
David Barsky
@davidbarsky
(i can’t answer that, but a good point. consider asking this in the the discord; this channel is not active)
Lucio Franco
@LucioFranco
@mitsuhiko hi! happy to answer questions :) So for the token thing I don't think it makes much sense compared to the poll_ready &mut self method. I think its a bit clunkier though I think they would achieve roughly the same thing. Could you explain more about what you mean about them being racy?
I believe in the case you brought up who ever has the exclusive reference to the service is the only one that can call poll and based on the contract it should submit or provide an error that is not related to readiness
Carl Lerche
@carllerche
@mitsuhiko when poll_ready returns Ready, it "reserves" capacity for 1 request
@mitsuhiko so, the caller is expected to call call soon after.. you still have to handle errors, but you shouldn't get a back pressure error
Carl Lerche
@carllerche
@mitsuhiko the service value is the token. Tower leveraged clone heavily.
Conceptually it works similar to an mpsc::Sender
David Barsky
@davidbarsky
@LucioFranco regarding racy behavior, here's a possible bug (with the caveat that this might not happen in practice): you lock on the service to check for readiness, release the lock, reacquire the lock, then call call. in the the time between those granular locks, a service could transition from ready to not-ready.
additionally when I say "lock", i mean a metaphorical lock.
this probably won't happen since you mentioned the contract is that the same entity should be calling poll_ready() and call(), but you can imagine a service behind a Mutex where multiple entities end up calling the same service.
Lucio Franco
@LucioFranco
but why would you use a mutex over say a channel in this case?
David Barsky
@davidbarsky
so, this is a race condition, but not a data race
it's easier than a channel
[let's move this to discord]
Armin Ronacher
@mitsuhiko
@carllerche so basically poll_ready reserves and if you would not want to act on the reservation you drop the service in that sense, right?
also that means you must never call without poll_ready, correct?
Carl Lerche
@carllerche
@mitsuhiko yep
we came to that contract after a bunch of iteration. We tried the other options, and the one where you must call poll_ready and reserve a slot works best
it also means it is common to clone a service to handle a single request
which is OK as it is usually a shallow clone
For concurrency I mean, you would clone services
which means that services that do not implement Clone cannot be used concurrently (stored in an Arc)
(services that are !Clone can process requests concurrently, but cannot receive requests concurrently)
@mitsuhiko I would love to get you more involved in Tower :heart: either way, we should migrate to discord: https://discord.gg/tokio
Armin Ronacher
@mitsuhiko
@carllerche the invite expired L(
Carl Lerche
@carllerche
@mitsuhiko well shit
David Barsky
@davidbarsky
Armin Ronacher
@mitsuhiko
joined
Carl Lerche
@carllerche
@mitsuhiko thanks for letting me know, I am working to fix
@mitsuhiko fixed!
Christian Legnitto
@LegNeato
Perhaps a dumb question, but does a tower client have to talk to a tower service? Or could it, say, be a client for a service written in another language? There doesn't appear to be too many examples of clients, just a lot of services.
Whoops, I'll ask in the discord