Class: Zotero::HTTPConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/zotero/http_config.rb

Overview

Configuration for HTTP requests and retry behavior

Constant Summary collapse

DEFAULTS =
{
  open_timeout: 30,
  read_timeout: 60,
  verify_ssl: true,
  retry_on_rate_limit: true,
  max_retries: 3,
  base_delay: 1.0
}.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**options) ⇒ HTTPConfig

Returns a new instance of HTTPConfig.



18
19
20
21
22
23
24
25
26
# File 'lib/zotero/http_config.rb', line 18

def initialize(**options)
  config = DEFAULTS.merge(options)
  @open_timeout = config[:open_timeout]
  @read_timeout = config[:read_timeout]
  @verify_ssl = config[:verify_ssl]
  @retry_on_rate_limit = config[:retry_on_rate_limit]
  @max_retries = config[:max_retries]
  @base_delay = config[:base_delay]
end

Instance Attribute Details

#base_delayObject

Returns the value of attribute base_delay.



6
7
8
# File 'lib/zotero/http_config.rb', line 6

def base_delay
  @base_delay
end

#max_retriesObject

Returns the value of attribute max_retries.



6
7
8
# File 'lib/zotero/http_config.rb', line 6

def max_retries
  @max_retries
end

#open_timeoutObject

Returns the value of attribute open_timeout.



6
7
8
# File 'lib/zotero/http_config.rb', line 6

def open_timeout
  @open_timeout
end

#read_timeoutObject

Returns the value of attribute read_timeout.



6
7
8
# File 'lib/zotero/http_config.rb', line 6

def read_timeout
  @read_timeout
end

#retry_on_rate_limitObject

Returns the value of attribute retry_on_rate_limit.



6
7
8
# File 'lib/zotero/http_config.rb', line 6

def retry_on_rate_limit
  @retry_on_rate_limit
end

#verify_sslObject

Returns the value of attribute verify_ssl.



6
7
8
# File 'lib/zotero/http_config.rb', line 6

def verify_ssl
  @verify_ssl
end

Class Method Details

.configure {|default| ... } ⇒ Object

Yields:



32
33
34
35
# File 'lib/zotero/http_config.rb', line 32

def self.configure
  yield(default) if block_given?
  default
end

.defaultObject



28
29
30
# File 'lib/zotero/http_config.rb', line 28

def self.default
  @default ||= new
end