Pool: Refactor logic for request methods

Make non-block request method internally call
the block based request method.
This commit is contained in:
syeopite 2024-11-14 17:21:04 -08:00
parent 621c6abfe6
commit aab9719e25
No known key found for this signature in database
GPG Key ID: A73C186DA3955A1A

View File

@ -25,7 +25,7 @@ module Invidious::ConnectionPool
end
{% for method in %w[get post put patch delete head options] %}
def {{method.id}}(*args, **kwargs)
def {{method.id}}(*args, **kwargs, &)
self.client do | client |
client.{{method.id}}(*args, **kwargs) do | response |
@ -39,14 +39,12 @@ module Invidious::ConnectionPool
end
def {{method.id}}(*args, **kwargs)
self.client do | client |
return response = client.{{method.id}}(*args, **kwargs)
{{method.id}}(*args, **kwargs) do | response |
return response
ensure
if response
response.body_io?.try &. skip_to_end
end
end
end
{% end %}
# Checks out a client in the pool