client.rb 1.2 KB

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