It might actually be worth splitting this PR into two.
This PR adds:
a new request_with_timeout interface that allows the caller to supply a duration. The existing request method will call into the new timeout method with None and the impl will not apply a timeout. No breaking changes.
a new Request type that holds the logic and ownership of the reply_to subscription so it can remove it from the client when the request is dropped. So whether a timeout happens, subject parsing error, or the caller gives up, ... doesn't matter, the reply_to will always be removed from the inbox mapping.
The Request type needs some improvement, but it does solve https://github.com/davidMcneil/rants/issues/4. I don't like the way drop is implemented, but it does seem reasonable. I'm not sure how much slower it will be since the lock could be expensive if the client is busy with a line of lock acquirers. I also think it might be worth setting a flag on error so we only attempt to cleanup if we absolutely need to.
I also don't like how the Request type is very involved with spawning the clients request handler. Not pretty at all. Still, I was hoping for some feedback :+1: / :-1: on the approach, and if :-1: , what I should do differently.
I know this does not directly relate to this PR, but this comment can be removed right?
3 doesn't actually change the connect behavior. We only make the round-trip wildcard request mapping subscription at the first call (just in time) to Client.request.
It might actually be worth splitting this PR into two.
This PR adds:
request_with_timeout
interface that allows the caller to supply a duration. The existingrequest
method will call into the new timeout method withNone
and the impl will not apply a timeout. No breaking changes.Request
type that holds the logic and ownership of the reply_to subscription so it can remove it from the client when the request is dropped. So whether a timeout happens, subject parsing error, or the caller gives up, ... doesn't matter, the reply_to will always be removed from the inbox mapping.The
Request
type needs some improvement, but it does solve https://github.com/davidMcneil/rants/issues/4. I don't like the way drop is implemented, but it does seem reasonable. I'm not sure how much slower it will be since the lock could be expensive if the client is busy with a line of lock acquirers. I also think it might be worth setting a flag on error so we only attempt to cleanup if we absolutely need to.I also don't like how the Request type is very involved with spawning the clients request handler. Not pretty at all. Still, I was hoping for some feedback :+1: / :-1: on the approach, and if :-1: , what I should do differently.