Class: Sumologic::Configuration

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

Overview

Centralized configuration for Sumo Logic client

Constant Summary collapse

API_VERSION =
'v1'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/sumologic/configuration.rb', line 12

def initialize
  # Authentication
  @access_id = ENV.fetch('SUMO_ACCESS_ID', nil)
  @access_key = ENV.fetch('SUMO_ACCESS_KEY', nil)
  @deployment = ENV['SUMO_DEPLOYMENT'] || 'us2'

  # Search job polling
  @initial_poll_interval = 2 # seconds - aggressive polling for faster response
  @max_poll_interval = 15 # seconds - slow down for large queries
  @poll_backoff_factor = 1.5 # increase interval by 50% each time

  # Timeouts and limits
  @timeout = 300 # seconds (5 minutes) - overall operation timeout
  @connect_timeout = ENV.fetch('SUMO_CONNECT_TIMEOUT', '10').to_i # seconds
  @read_timeout = ENV.fetch('SUMO_READ_TIMEOUT', '60').to_i # seconds
  @max_messages_per_request = 10_000

  # Retry configuration
  @max_retries = ENV.fetch('SUMO_MAX_RETRIES', '3').to_i
  @retry_base_delay = ENV.fetch('SUMO_RETRY_BASE_DELAY', '1.0').to_f # seconds
  @retry_max_delay = ENV.fetch('SUMO_RETRY_MAX_DELAY', '30.0').to_f # seconds

  # Rate limiting (default: 5 workers, 250ms delay)
  @max_workers = ENV.fetch('SUMO_MAX_WORKERS', '5').to_i
  @request_delay = ENV.fetch('SUMO_REQUEST_DELAY', '0.25').to_f
end

Instance Attribute Details

#access_idObject

Returns the value of attribute access_id.



6
7
8
# File 'lib/sumologic/configuration.rb', line 6

def access_id
  @access_id
end

#access_keyObject

Returns the value of attribute access_key.



6
7
8
# File 'lib/sumologic/configuration.rb', line 6

def access_key
  @access_key
end

#connect_timeoutObject

Returns the value of attribute connect_timeout.



6
7
8
# File 'lib/sumologic/configuration.rb', line 6

def connect_timeout
  @connect_timeout
end

#deploymentObject

Returns the value of attribute deployment.



6
7
8
# File 'lib/sumologic/configuration.rb', line 6

def deployment
  @deployment
end

#initial_poll_intervalObject

Returns the value of attribute initial_poll_interval.



6
7
8
# File 'lib/sumologic/configuration.rb', line 6

def initial_poll_interval
  @initial_poll_interval
end

#max_messages_per_requestObject

Returns the value of attribute max_messages_per_request.



6
7
8
# File 'lib/sumologic/configuration.rb', line 6

def max_messages_per_request
  @max_messages_per_request
end

#max_poll_intervalObject

Returns the value of attribute max_poll_interval.



6
7
8
# File 'lib/sumologic/configuration.rb', line 6

def max_poll_interval
  @max_poll_interval
end

#max_retriesObject

Returns the value of attribute max_retries.



6
7
8
# File 'lib/sumologic/configuration.rb', line 6

def max_retries
  @max_retries
end

#max_workersObject

Returns the value of attribute max_workers.



6
7
8
# File 'lib/sumologic/configuration.rb', line 6

def max_workers
  @max_workers
end

#poll_backoff_factorObject

Returns the value of attribute poll_backoff_factor.



6
7
8
# File 'lib/sumologic/configuration.rb', line 6

def poll_backoff_factor
  @poll_backoff_factor
end

#read_timeoutObject

Returns the value of attribute read_timeout.



6
7
8
# File 'lib/sumologic/configuration.rb', line 6

def read_timeout
  @read_timeout
end

#request_delayObject

Returns the value of attribute request_delay.



6
7
8
# File 'lib/sumologic/configuration.rb', line 6

def request_delay
  @request_delay
end

#retry_base_delayObject

Returns the value of attribute retry_base_delay.



6
7
8
# File 'lib/sumologic/configuration.rb', line 6

def retry_base_delay
  @retry_base_delay
end

#retry_max_delayObject

Returns the value of attribute retry_max_delay.



6
7
8
# File 'lib/sumologic/configuration.rb', line 6

def retry_max_delay
  @retry_max_delay
end

#timeoutObject

Returns the value of attribute timeout.



6
7
8
# File 'lib/sumologic/configuration.rb', line 6

def timeout
  @timeout
end

Instance Method Details

#base_urlObject



39
40
41
# File 'lib/sumologic/configuration.rb', line 39

def base_url
  @base_url ||= build_base_url
end

#base_url_v2Object

Base URL for v2 API endpoints (Content Library, etc.)



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

def base_url_v2
  @base_url_v2 ||= build_base_url('v2')
end

#validate!Object



52
53
54
55
# File 'lib/sumologic/configuration.rb', line 52

def validate!
  raise AuthenticationError, 'SUMO_ACCESS_ID not set' unless @access_id
  raise AuthenticationError, 'SUMO_ACCESS_KEY not set' unless @access_key
end

#web_ui_base_urlObject



48
49
50
# File 'lib/sumologic/configuration.rb', line 48

def web_ui_base_url
  @web_ui_base_url ||= build_web_ui_base_url
end