Class: Sumologic::Configuration
- Inherits:
-
Object
- Object
- Sumologic::Configuration
- Defined in:
- lib/sumologic/configuration.rb
Overview
Centralized configuration for Sumo Logic client
Constant Summary collapse
- API_VERSION =
'v1'
Instance Attribute Summary collapse
-
#access_id ⇒ Object
Returns the value of attribute access_id.
-
#access_key ⇒ Object
Returns the value of attribute access_key.
-
#connect_timeout ⇒ Object
Returns the value of attribute connect_timeout.
-
#deployment ⇒ Object
Returns the value of attribute deployment.
-
#initial_poll_interval ⇒ Object
Returns the value of attribute initial_poll_interval.
-
#max_messages_per_request ⇒ Object
Returns the value of attribute max_messages_per_request.
-
#max_poll_interval ⇒ Object
Returns the value of attribute max_poll_interval.
-
#max_retries ⇒ Object
Returns the value of attribute max_retries.
-
#max_workers ⇒ Object
Returns the value of attribute max_workers.
-
#poll_backoff_factor ⇒ Object
Returns the value of attribute poll_backoff_factor.
-
#read_timeout ⇒ Object
Returns the value of attribute read_timeout.
-
#request_delay ⇒ Object
Returns the value of attribute request_delay.
-
#retry_base_delay ⇒ Object
Returns the value of attribute retry_base_delay.
-
#retry_max_delay ⇒ Object
Returns the value of attribute retry_max_delay.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Instance Method Summary collapse
- #base_url ⇒ Object
-
#base_url_v2 ⇒ Object
Base URL for v2 API endpoints (Content Library, etc.).
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #validate! ⇒ Object
- #web_ui_base_url ⇒ Object
Constructor Details
#initialize ⇒ Configuration
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_id ⇒ Object
Returns the value of attribute access_id.
6 7 8 |
# File 'lib/sumologic/configuration.rb', line 6 def access_id @access_id end |
#access_key ⇒ Object
Returns the value of attribute access_key.
6 7 8 |
# File 'lib/sumologic/configuration.rb', line 6 def access_key @access_key end |
#connect_timeout ⇒ Object
Returns the value of attribute connect_timeout.
6 7 8 |
# File 'lib/sumologic/configuration.rb', line 6 def connect_timeout @connect_timeout end |
#deployment ⇒ Object
Returns the value of attribute deployment.
6 7 8 |
# File 'lib/sumologic/configuration.rb', line 6 def deployment @deployment end |
#initial_poll_interval ⇒ Object
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_request ⇒ Object
Returns the value of attribute max_messages_per_request.
6 7 8 |
# File 'lib/sumologic/configuration.rb', line 6 def @max_messages_per_request end |
#max_poll_interval ⇒ Object
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_retries ⇒ Object
Returns the value of attribute max_retries.
6 7 8 |
# File 'lib/sumologic/configuration.rb', line 6 def max_retries @max_retries end |
#max_workers ⇒ Object
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_factor ⇒ Object
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_timeout ⇒ Object
Returns the value of attribute read_timeout.
6 7 8 |
# File 'lib/sumologic/configuration.rb', line 6 def read_timeout @read_timeout end |
#request_delay ⇒ Object
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_delay ⇒ Object
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_delay ⇒ Object
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 |
#timeout ⇒ Object
Returns the value of attribute timeout.
6 7 8 |
# File 'lib/sumologic/configuration.rb', line 6 def timeout @timeout end |
Instance Method Details
#base_url ⇒ Object
39 40 41 |
# File 'lib/sumologic/configuration.rb', line 39 def base_url @base_url ||= build_base_url end |
#base_url_v2 ⇒ Object
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_url ⇒ Object
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 |