Class: Fulfil::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/fulfil/configuration.rb

Overview

The ‘Fulfil::Configuration` contains the available configuration options for the `Fulfil` gem.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



38
39
40
41
42
# File 'lib/fulfil/configuration.rb', line 38

def initialize
  @retry_on_rate_limit = false
  @retry_on_rate_limit_wait = 1
  @logger = Logger.new($stderr)
end

Instance Attribute Details

#loggerLogger?

Allows the client to configure a logger. Logs are output to $stderr by default.

Examples:

Use a logger to log the API rate limit hits

Fulfil.configure do |config|
  config.logger = Logger.new($stderr)
end

Returns:

  • (Logger, nil)


36
37
38
# File 'lib/fulfil/configuration.rb', line 36

def logger
  @logger
end

#rate_limit_notification_handlerProc?

Allows the client to configure a notification handler. Can be used by APM tools to monitor the number of rate limit hits.

Examples:

Use APM to monitor the API rate limit hits

Fulfil.configure do |config|
  config.rate_limit_notification_handler = proc {
    FakeAPM.increment_counter('fulfil.rate_limit_exceeded')
  }
end

Returns:

  • (Proc, nil)


25
26
27
# File 'lib/fulfil/configuration.rb', line 25

def rate_limit_notification_handler
  @rate_limit_notification_handler
end

#retry_on_rate_limitObject

Allow the ‘Fulfil::Client` to automatically retry when the rate limit is hit. By default, the `Fulfil::Client` will wait 1 second before retrying again.



11
12
13
# File 'lib/fulfil/configuration.rb', line 11

def retry_on_rate_limit
  @retry_on_rate_limit
end

#retry_on_rate_limit_waitObject

Returns the value of attribute retry_on_rate_limit_wait.



12
13
14
# File 'lib/fulfil/configuration.rb', line 12

def retry_on_rate_limit_wait
  @retry_on_rate_limit_wait
end

Instance Method Details

#retry_on_rate_limit?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/fulfil/configuration.rb', line 44

def retry_on_rate_limit?
  @retry_on_rate_limit
end