문제

Since Faraday doesn't have documentation, I wasn't able to find it out anywhere. What is "timeout" and what "open timeout" in Faraday?

도움이 되었습니까?

해결책

If you look at the source code at https://github.com/lostisland/faraday/blob/master/lib/faraday/request.rb then you'll see:

#   :timeout      - open/read timeout Integer in seconds
#   :open_timeout - read timeout Integer in seconds

Not very helpful, perhaps? Well, if you look at Faraday's Net::HTTP adapter at https://github.com/lostisland/faraday/blob/master/lib/faraday/adapter/net_http.rb, you'll see:

http.read_timeout = http.open_timeout = req[:timeout] if req[:timeout]
http.open_timeout = req[:open_timeout]                if req[:open_timeout]

So Faraday's open_timeout is equivalent to Net::HTTP's open_timeout which is documented as:

Number of seconds to wait for the connection to open. Any number may be used, including Floats for fractional seconds. If the HTTP object cannot open a connection in this many seconds, it raises a TimeoutError exception.

And Faraday's timeout is equivalent to Net::HTTP's read_timeout which is documented as:

Number of seconds to wait for one block to be read (via one read(2) call). Any number may be used, including Floats for fractional seconds. If the HTTP object cannot read data in this many seconds, it raises a TimeoutError exception.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top