Extrac common timeout to a constant on Github::Client

parent 6f642e3f
module Github module Github
class Client class Client
TIMEOUT = 60
attr_reader :connection, :rate_limit attr_reader :connection, :rate_limit
def initialize(options) def initialize(options)
@connection = Faraday.new(url: options.fetch(:url, root_endpoint)) do |faraday| @connection = Faraday.new(url: options.fetch(:url, root_endpoint)) do |faraday|
faraday.options.open_timeout = options.fetch(:timeout, 60) faraday.options.open_timeout = options.fetch(:timeout, TIMEOUT)
faraday.options.timeout = options.fetch(:timeout, 60) faraday.options.timeout = options.fetch(:timeout, TIMEOUT)
faraday.authorization 'token', options.fetch(:token) faraday.authorization 'token', options.fetch(:token)
faraday.adapter :net_http faraday.adapter :net_http
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment