Class: Procore::Configuration
- Inherits:
-
Object
- Object
- Procore::Configuration
- Defined in:
- lib/procore/configuration.rb
Overview
Holds the configuration for the Procore gem.
Instance Attribute Summary collapse
-
#host ⇒ String
Base API host name.
-
#logger ⇒ Logger?
Instance of a Logger.
-
#max_retries ⇒ Integer
Number of times to retry a failed API call.
-
#timeout ⇒ Float
Threshold for canceling an API request.
-
#user_agent ⇒ String
User Agent sent with each API request.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
80 81 82 83 84 85 86 |
# File 'lib/procore/configuration.rb', line 80 def initialize @host = Procore::Defaults::API_ENDPOINT @logger = nil @max_retries = 1 @timeout = 1.0 @user_agent = Procore::Defaults::USER_AGENT end |
Instance Attribute Details
#host ⇒ String
defaults to Defaults::API_ENDPOINT
Base API host name. Alter this depending on your environment - in a staging or test environment you may want to point this at a sandbox instead of production.
33 34 35 |
# File 'lib/procore/configuration.rb', line 33 def host @host end |
#logger ⇒ Logger?
defaults to nil
Instance of a Logger. This gem will log information about requests, responses and other things it might be doing. In a Rails application it should be set to Rails.logger
43 44 45 |
# File 'lib/procore/configuration.rb', line 43 def logger @logger end |
#max_retries ⇒ Integer
Defaults to 1
Number of times to retry a failed API call. Reasons an API call could potentially fail:
-
Service is briefly down or unreachable
-
Timeout hit - service is experiencing immense load or mid restart
-
Because computers
Would recommend 3-5 for production use. Has exponential backoff - first request waits a 1.5s after a failure, next one 2.25s, next one 3.375s, 5.0, etc.
59 60 61 |
# File 'lib/procore/configuration.rb', line 59 def max_retries @max_retries end |
#timeout ⇒ Float
defaults to 1.0
Threshold for canceling an API request. If a request takes longer than this value it will automatically cancel.
68 69 70 |
# File 'lib/procore/configuration.rb', line 68 def timeout @timeout end |
#user_agent ⇒ String
defaults to Defaults::USER_AGENT
User Agent sent with each API request. API requests must have a user agent set. It is recomended to set the user agent to the name of your application.
78 79 80 |
# File 'lib/procore/configuration.rb', line 78 def user_agent @user_agent end |