You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add :request event listener for particular client instance
client = HTTP.auth("Bearer 123")
client.on(:request) { ... }
With proper architecture, IMO it will become possible to extract timeouts out of connection/client completely.
—
Reply to this email directly or view it on GitHub.
@zanker this kind of API can be useful for people writing things like testing frameworks who want to instrument clients for various purposes. Right now they're using monkeypatches.
What comes to VCR support (from ML) actually that can't be done without monkey patching anyway :D And it's already done (webmock backend for VCR). I was mostly thinking about kind of a way to "monitor" progress. Like log requests and timings, probably sending "halt" to client on some events...
Would either of the proposed APsI allow modification of the request flow. Ie, could an on(:request) bypass the actual HTTP request in favor of a cached response instead? Allowing a "spy" to do that seems a little unintuitive but maybe not out of the question.
@tarcieri if we are talking about events, then I don't see how it can modify workflow. I mean I would like to avoid (and I know you too) middleware alike architecture.
RE: logging, I probably wouldn't complicate it too much. I think hooks as extension points would be great, but they're not required to make logging better. Couldn't we just add a debug option on configuration and a logger class? If we choose to add hooks for extension, the logger could be registered as a default hook if the option is true.
Until that time, I think these could be two separate issues. Any opinions?
@pezra I think hooks should be different from composition. Hooks should allow you to execute code when a thing occurs. But it should not block other code from running.
Instead I think it'd be nice to have a connection class, or request class or whatever that can be substituted in favor of a dummy request object via composition if you required that kind of behavior.
Activity
zanker commentedon Apr 12, 2015
Timeouts requires you have direct access to socket write and reads. You can't do that with an API.
I'm not sure I see an advantage to this. Celluloid already lets you do the async bits. Seems like unneeded abstraction.
Sent from my iPhone
tarcieri commentedon Apr 12, 2015
@zanker this kind of API can be useful for people writing things like testing frameworks who want to instrument clients for various purposes. Right now they're using monkeypatches.
See this discussion:
https://groups.google.com/forum/#!topic/httprb/ISln457aPUc
ixti commentedon Apr 12, 2015
What comes to VCR support (from ML) actually that can't be done without monkey patching anyway :D And it's already done (webmock backend for VCR). I was mostly thinking about kind of a way to "monitor" progress. Like log requests and timings, probably sending "halt" to client on some events...
tarcieri commentedon Apr 13, 2015
It'd be nice to have something like
Reel::Spyin http.rb:https://github.com/celluloid/reel/wiki/Spy
A system like this would make it easy to implement.
ixti commentedon Apr 27, 2015
Proposed API:
pezra commentedon Jul 23, 2015
Would either of the proposed APsI allow modification of the request flow. Ie, could an
on(:request)bypass the actual HTTP request in favor of a cached response instead? Allowing a "spy" to do that seems a little unintuitive but maybe not out of the question.tarcieri commentedon Jul 28, 2015
@pezra it could. It doesn't have to be called "spy"
ixti commentedon Jul 28, 2015
@tarcieri if we are talking about events, then I don't see how it can modify workflow. I mean I would like to avoid (and I know you too) middleware alike architecture.
Senjai commentedon Jul 28, 2015
RE: logging, I probably wouldn't complicate it too much. I think hooks as extension points would be great, but they're not required to make logging better. Couldn't we just add a debug option on configuration and a logger class? If we choose to add hooks for extension, the logger could be registered as a default hook if the option is true.
Until that time, I think these could be two separate issues. Any opinions?
Senjai commentedon Jul 28, 2015
@pezra I think hooks should be different from composition. Hooks should allow you to execute code when a thing occurs. But it should not block other code from running.
Instead I think it'd be nice to have a connection class, or request class or whatever that can be substituted in favor of a dummy request object via composition if you required that kind of behavior.
pezra commentedon Jul 29, 2015
@ixti, I agree that allowing an event handler to modify the flow send awkward.
@Senjai, an option specify the connection class to use might be workable. Wild such a PR be accepted?
tarcieri commentedon Jul 29, 2015
@Senjai we already have
HTTP::ConnectionandHTTP::Requestclasses@pezra if it's not too invasive and doesn't involve weird delegators/proxy objects
6 remaining items
[-]Add support for events.[/-][+]Event system + activity logging[/+]ixti commentedon Oct 14, 2018
Resolved by #499