Module: SalesforceOrm::RestforceClient

Defined in:
lib/salesforce-orm/restforce_client.rb

Class Method Summary collapse

Class Method Details

.instanceObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/salesforce-orm/restforce_client.rb', line 8

def instance
  # TODO need to verify with Sidekiq

  # Making Restforce object a thread local variable to avoid making
  # authentication request for each query we make to SalesForce.
  # With this, only one authentication request will be made to SalesForce
  # per request.
  #
  # Thread local variable will guarantee us a new Restforce object for each request.
  #
  # If this was a singleton object for process, then we'll have to
  # manually refresh authentication token for each request
  Thread.current[:salesforce_orm_restforce_client] ||= Restforce.new(Configuration.restforce_config || {})
end