Class: Optimizely::Helpers::OptimizelySdkSettings

Inherits:
Object
  • Object
show all
Defined in:
lib/optimizely/helpers/sdk_settings.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(disable_odp: false, segments_cache_size: Constants::ODP_SEGMENTS_CACHE_CONFIG[:DEFAULT_CAPACITY], segments_cache_timeout_in_secs: Constants::ODP_SEGMENTS_CACHE_CONFIG[:DEFAULT_TIMEOUT_SECONDS], odp_segments_cache: nil, odp_segment_manager: nil, odp_event_manager: nil, odp_segment_request_timeout: nil, odp_event_request_timeout: nil, odp_event_flush_interval: nil) ⇒ OptimizelySdkSettings

Contains configuration used for Optimizely Project initialization.

Parameters:

  • disable_odp (defaults to: false)
    • Set this flag to true (default = false) to disable ODP features.

  • segments_cache_size (defaults to: Constants::ODP_SEGMENTS_CACHE_CONFIG[:DEFAULT_CAPACITY])
    • The maximum size of audience segments cache (optional. default = 10,000). Set to zero to disable caching.

  • segments_cache_timeout_in_secs (defaults to: Constants::ODP_SEGMENTS_CACHE_CONFIG[:DEFAULT_TIMEOUT_SECONDS])
    • The timeout in seconds of audience segments cache (optional. default = 600). Set to zero to disable timeout.

  • odp_segments_cache (defaults to: nil)
    • A custom odp segments cache. Required methods include: ‘save(key, value)`, `lookup(key) -> value`, and `reset()`

  • odp_segment_manager (defaults to: nil)
    • A custom odp segment manager. Required method is: ‘fetch_qualified_segments(user_key, user_value, options)`.

  • odp_event_manager (defaults to: nil)
    • A custom odp event manager. Required method is: ‘send_event(type:, action:, identifiers:, data:)`

  • odp_segment_request_timeout (defaults to: nil)
    • Time to wait in seconds for fetch_qualified_segments (optional. default = 10).

  • odp_event_request_timeout (defaults to: nil)
    • Time to wait in seconds for send_odp_events (optional. default = 10).

  • odp_event_flush_interval (defaults to: nil)
    • Time to wait in seconds for odp events to accumulate before sending (optional. default = 1).



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/optimizely/helpers/sdk_settings.rb', line 38

def initialize(
  disable_odp: false,
  segments_cache_size: Constants::ODP_SEGMENTS_CACHE_CONFIG[:DEFAULT_CAPACITY],
  segments_cache_timeout_in_secs: Constants::ODP_SEGMENTS_CACHE_CONFIG[:DEFAULT_TIMEOUT_SECONDS],
  odp_segments_cache: nil,
  odp_segment_manager: nil,
  odp_event_manager: nil,
  odp_segment_request_timeout: nil,
  odp_event_request_timeout: nil,
  odp_event_flush_interval: nil
)
  @odp_disabled = disable_odp
  @segments_cache_size = segments_cache_size
  @segments_cache_timeout_in_secs = segments_cache_timeout_in_secs
  @odp_segments_cache = odp_segments_cache
  @odp_segment_manager = odp_segment_manager
  @odp_event_manager = odp_event_manager
  @fetch_segments_timeout = odp_segment_request_timeout
  @odp_event_timeout = odp_event_request_timeout
  @odp_flush_interval = odp_event_flush_interval
end

Instance Attribute Details

#fetch_segments_timeoutObject

Returns the value of attribute fetch_segments_timeout.



24
25
26
# File 'lib/optimizely/helpers/sdk_settings.rb', line 24

def fetch_segments_timeout
  @fetch_segments_timeout
end

#odp_disabledObject

Returns the value of attribute odp_disabled.



24
25
26
# File 'lib/optimizely/helpers/sdk_settings.rb', line 24

def odp_disabled
  @odp_disabled
end

#odp_event_managerObject

Returns the value of attribute odp_event_manager.



24
25
26
# File 'lib/optimizely/helpers/sdk_settings.rb', line 24

def odp_event_manager
  @odp_event_manager
end

#odp_event_timeoutObject

Returns the value of attribute odp_event_timeout.



24
25
26
# File 'lib/optimizely/helpers/sdk_settings.rb', line 24

def odp_event_timeout
  @odp_event_timeout
end

#odp_flush_intervalObject

Returns the value of attribute odp_flush_interval.



24
25
26
# File 'lib/optimizely/helpers/sdk_settings.rb', line 24

def odp_flush_interval
  @odp_flush_interval
end

#odp_segment_managerObject

Returns the value of attribute odp_segment_manager.



24
25
26
# File 'lib/optimizely/helpers/sdk_settings.rb', line 24

def odp_segment_manager
  @odp_segment_manager
end

#odp_segments_cacheObject

Returns the value of attribute odp_segments_cache.



24
25
26
# File 'lib/optimizely/helpers/sdk_settings.rb', line 24

def odp_segments_cache
  @odp_segments_cache
end

#segments_cache_sizeObject

Returns the value of attribute segments_cache_size.



24
25
26
# File 'lib/optimizely/helpers/sdk_settings.rb', line 24

def segments_cache_size
  @segments_cache_size
end

#segments_cache_timeout_in_secsObject

Returns the value of attribute segments_cache_timeout_in_secs.



24
25
26
# File 'lib/optimizely/helpers/sdk_settings.rb', line 24

def segments_cache_timeout_in_secs
  @segments_cache_timeout_in_secs
end