client.rb 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. class Sequencer
  2. class Unit
  3. module Zendesk
  4. class Client < Sequencer::Unit::Common::Provider::Fallback
  5. provides :client
  6. private
  7. def client
  8. ZendeskAPI::Client.new do |config|
  9. config.url = Setting.get('import_zendesk_endpoint')
  10. # Basic / Token Authentication
  11. config.username = Setting.get('import_zendesk_endpoint_username')
  12. config.token = Setting.get('import_zendesk_endpoint_key')
  13. # when hitting the rate limit, sleep automatically,
  14. # then retry the request.
  15. config.retry = true
  16. # disable cache to avoid unneeded memory consumption
  17. # since we are using each object only once
  18. # Inspired by: https://medium.com/swiftype-engineering/using-jmat-to-find-analyze-memory-in-jruby-1c4196c1ec72
  19. config.cache = false
  20. # increase timeouts to avoid network issues.
  21. config.client_options = {
  22. request: {
  23. open_timeout: 20, # default is 10
  24. timeout: 120, # default is 60
  25. },
  26. }
  27. end
  28. end
  29. end
  30. end
  31. end
  32. end