mirror of
https://github.com/iv-org/invidious.git
synced 2025-01-10 03:20:35 +05:30
Pool: Refactor logic for request methods
Make non-block request method internally call the block based request method.
This commit is contained in:
parent
621c6abfe6
commit
aab9719e25
@ -25,7 +25,7 @@ module Invidious::ConnectionPool
|
|||||||
end
|
end
|
||||||
|
|
||||||
{% for method in %w[get post put patch delete head options] %}
|
{% 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 |
|
self.client do | client |
|
||||||
client.{{method.id}}(*args, **kwargs) do | response |
|
client.{{method.id}}(*args, **kwargs) do | response |
|
||||||
|
|
||||||
@ -39,12 +39,10 @@ module Invidious::ConnectionPool
|
|||||||
end
|
end
|
||||||
|
|
||||||
def {{method.id}}(*args, **kwargs)
|
def {{method.id}}(*args, **kwargs)
|
||||||
self.client do | client |
|
{{method.id}}(*args, **kwargs) do | response |
|
||||||
return response = client.{{method.id}}(*args, **kwargs)
|
return response
|
||||||
ensure
|
ensure
|
||||||
if response
|
response.body_io?.try &. skip_to_end
|
||||||
response.body_io?.try &. skip_to_end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
{% end %}
|
{% end %}
|
||||||
|
Loading…
Reference in New Issue
Block a user