Sha256: b167e35b530c17f15c6683bf9ff714428baa11c59b31b9ad627f7bb843aca521
Contents?: true
Size: 721 Bytes
Versions: 4
Compression:
Stored size: 721 Bytes
Contents
# frozen_string_literal: true class EzClient::PersistentClient extend Forwardable def_delegators :http_client, :build_request, :default_options, :timeout def initialize(origin, keep_alive_timeout) self.origin = origin self.keep_alive_timeout = keep_alive_timeout self.last_request_at = nil end def perform(*args) http_client.perform(*args).tap do self.last_request_at = EzClient.get_time end end def timed_out? last_request_at && EzClient.get_time - last_request_at >= keep_alive_timeout end private attr_accessor :origin, :keep_alive_timeout, :last_request_at def http_client @http_client ||= HTTP.persistent(origin, timeout: keep_alive_timeout) end end
Version data entries
4 entries across 4 versions & 1 rubygems