Class: ShopCircle::Orbit::Configuration
- Inherits:
-
Object
- Object
- ShopCircle::Orbit::Configuration
- Defined in:
- lib/shopcircle/orbit/configuration.rb
Instance Attribute Summary collapse
-
#api_url ⇒ Object
Returns the value of attribute api_url.
-
#base_retry_delay ⇒ Object
Returns the value of attribute base_retry_delay.
-
#client_id ⇒ Object
Returns the value of attribute client_id.
-
#client_secret ⇒ Object
Returns the value of attribute client_secret.
-
#device_id ⇒ Object
Returns the value of attribute device_id.
-
#exclude_paths ⇒ Object
Returns the value of attribute exclude_paths.
-
#flush_interval ⇒ Object
Returns the value of attribute flush_interval.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#max_batch_size ⇒ Object
Returns the value of attribute max_batch_size.
-
#max_queue_size ⇒ Object
Returns the value of attribute max_queue_size.
-
#max_retries ⇒ Object
Returns the value of attribute max_retries.
-
#on_error ⇒ Object
Returns the value of attribute on_error.
-
#redact_pii ⇒ Object
Returns the value of attribute redact_pii.
-
#request_timeout ⇒ Object
Returns the value of attribute request_timeout.
-
#stub ⇒ Object
Returns the value of attribute stub.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#inspect ⇒ Object
Redact sensitive fields from inspect output to prevent accidental credential leakage in logs/debugging.
- #resolved_logger ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/shopcircle/orbit/configuration.rb', line 24 def initialize @client_id = nil @client_secret = nil @api_url = nil @device_id = nil @flush_interval = 2 @max_batch_size = 10 @max_queue_size = 1_000 @max_retries = 3 @base_retry_delay = 1 @request_timeout = 10 @logger = nil @stub = false @on_error = nil @redact_pii = true @exclude_paths = [] end |
Instance Attribute Details
#api_url ⇒ Object
Returns the value of attribute api_url.
8 9 10 |
# File 'lib/shopcircle/orbit/configuration.rb', line 8 def api_url @api_url end |
#base_retry_delay ⇒ Object
Returns the value of attribute base_retry_delay.
8 9 10 |
# File 'lib/shopcircle/orbit/configuration.rb', line 8 def base_retry_delay @base_retry_delay end |
#client_id ⇒ Object
Returns the value of attribute client_id.
8 9 10 |
# File 'lib/shopcircle/orbit/configuration.rb', line 8 def client_id @client_id end |
#client_secret ⇒ Object
Returns the value of attribute client_secret.
8 9 10 |
# File 'lib/shopcircle/orbit/configuration.rb', line 8 def client_secret @client_secret end |
#device_id ⇒ Object
Returns the value of attribute device_id.
8 9 10 |
# File 'lib/shopcircle/orbit/configuration.rb', line 8 def device_id @device_id end |
#exclude_paths ⇒ Object
Returns the value of attribute exclude_paths.
8 9 10 |
# File 'lib/shopcircle/orbit/configuration.rb', line 8 def exclude_paths @exclude_paths end |
#flush_interval ⇒ Object
Returns the value of attribute flush_interval.
8 9 10 |
# File 'lib/shopcircle/orbit/configuration.rb', line 8 def flush_interval @flush_interval end |
#logger ⇒ Object
Returns the value of attribute logger.
8 9 10 |
# File 'lib/shopcircle/orbit/configuration.rb', line 8 def logger @logger end |
#max_batch_size ⇒ Object
Returns the value of attribute max_batch_size.
8 9 10 |
# File 'lib/shopcircle/orbit/configuration.rb', line 8 def max_batch_size @max_batch_size end |
#max_queue_size ⇒ Object
Returns the value of attribute max_queue_size.
8 9 10 |
# File 'lib/shopcircle/orbit/configuration.rb', line 8 def max_queue_size @max_queue_size end |
#max_retries ⇒ Object
Returns the value of attribute max_retries.
8 9 10 |
# File 'lib/shopcircle/orbit/configuration.rb', line 8 def max_retries @max_retries end |
#on_error ⇒ Object
Returns the value of attribute on_error.
8 9 10 |
# File 'lib/shopcircle/orbit/configuration.rb', line 8 def on_error @on_error end |
#redact_pii ⇒ Object
Returns the value of attribute redact_pii.
8 9 10 |
# File 'lib/shopcircle/orbit/configuration.rb', line 8 def redact_pii @redact_pii end |
#request_timeout ⇒ Object
Returns the value of attribute request_timeout.
8 9 10 |
# File 'lib/shopcircle/orbit/configuration.rb', line 8 def request_timeout @request_timeout end |
#stub ⇒ Object
Returns the value of attribute stub.
8 9 10 |
# File 'lib/shopcircle/orbit/configuration.rb', line 8 def stub @stub end |
Instance Method Details
#inspect ⇒ Object
Redact sensitive fields from inspect output to prevent accidental credential leakage in logs/debugging.
69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/shopcircle/orbit/configuration.rb', line 69 def inspect redacted = instance_variables.each_with_object({}) do |var, hash| val = instance_variable_get(var) hash[var] = if var == :@client_secret && val "[REDACTED]" else val end end "#<#{self.class} #{redacted.map { |k, v| "#{k}=#{v.inspect}" }.join(', ')}>" end |
#resolved_logger ⇒ Object
63 64 65 |
# File 'lib/shopcircle/orbit/configuration.rb', line 63 def resolved_logger @logger || default_logger end |
#validate! ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/shopcircle/orbit/configuration.rb', line 42 def validate! raise ConfigurationError, "client_id is required" if @client_id.nil? || @client_id.to_s.empty? raise ConfigurationError, "api_url is required" if @api_url.nil? || @api_url.to_s.empty? raise ConfigurationError, "device_id max 128 chars" if @device_id && @device_id.to_s.length > 128 validate_positive!(:flush_interval, @flush_interval) validate_positive!(:max_batch_size, @max_batch_size) validate_positive!(:max_queue_size, @max_queue_size) validate_positive!(:request_timeout, @request_timeout) validate_positive!(:base_retry_delay, @base_retry_delay) raise ConfigurationError, "max_retries must be >= 0" if !@max_retries.is_a?(Numeric) || @max_retries < 0 uri = URI.parse(@api_url.to_s) unless uri.scheme == "https" || ENV["ORBIT_ALLOW_HTTP"] == "1" raise ConfigurationError, "api_url must use https:// in production. Set ORBIT_ALLOW_HTTP=1 for local development." end if uri.scheme != "https" resolved_logger.warn("[shopcircle-orbit] WARNING: Sending data over plaintext HTTP. Do not use in production.") end end |