-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support keep-alive #5
Comments
hi @duncan-bayne. is this the same Keep Alive as described here https://api.developer.betfair.com/services/webapps/docs/display/1smk3cen4v3lu3yomq5qye0ni/Keep+Alive ? if so, that appears to be a session extender implemented by Betfair rather than the keep-alive HTTP header that you linked to. (for what it's worth, this looks like it might be a useful addition too.) If it's the HTTP keep-alive that you're referring to, do you have any links that show that Betfair recommend a persistent connection? (makes sense, but just want to be sure!) |
nvm w.r.t. my last question, found something:
look forward to the PR! |
Okay, so I might have been a little optimistic in describing the PR as coming 'soon' :) It turns out HTTPI doesn't support keep-alive, at least not yet. I've modified my app to use Faraday with net-http-persistent. That works really nicely; connections are kept open, and overall processing time drops way down. So ... would you be open to the idea of a PR that switches this library over to using Faraday? It'd be a pretty major change. |
crap. hmm, Faraday isn't desperately different in design to HTTPI, in that it supports multiple adapters, so in theory it should be possible to write a net-http-persistent adapter for HTTPI or modify the net-http adapter or something. i'll take a look this evening! |
not forgotten about this, just been super busy. hope to look at it in the next week or so 😘 |
riight so, finally got around to looking at this. because we're using HTTPI, kind of the advantage of it is you can use whichever underlying client library you want (whether we want to continue this way is another question). there's already a net-http-persistent adapter for HTTPI, and at least one other adapter (httpclient) which supports keep-alive, so in my view we don't need to make any changes except to the README to make it clear that it's recommended that you use a keep-alive connection. to use net_http_persistent, simply: require 'betfair'
HTTPI.adapter = :net_http_persistent # because it's lower precedence than net-http as far as i can tell, httpclient automatically caches connections where the server supports it, so simply using that adapter should be enough to use a persistent connection. because the httpclient has the highest precedence of the adapters, simply having it installed and in your load path is enough to use that adapter for betfair. i'll update the readme now. |
Support HTTP keep-alive for speedier requests.
(I'll be addressing this with a PR soon ...)
The text was updated successfully, but these errors were encountered: