Class: SplitIoClient::SplitConfig
- Inherits:
-
Object
- Object
- SplitIoClient::SplitConfig
- Defined in:
- lib/splitclient-rb/split_config.rb
Overview
This class manages configuration options for the split client library. If not custom configuration is required the default configuration values will be used
Instance Attribute Summary collapse
-
#auth_retry_back_off_base ⇒ Object
Returns the value of attribute auth_retry_back_off_base.
-
#auth_service_url ⇒ Object
Returns the value of attribute auth_service_url.
-
#base_uri ⇒ String
The base URL for split API end points.
-
#block_until_ready ⇒ Integer
The number of seconds to wait for SDK readiness or false to disable waiting.
-
#cache_adapter ⇒ Object
The cache adapter to store splits/segments in.
-
#cache_ttl ⇒ Object
Returns the value of attribute cache_ttl.
-
#connection_timeout ⇒ Int
The connection timeout for network connections in seconds.
-
#counter_refresh_rate ⇒ Object
Returns the value of attribute counter_refresh_rate.
-
#debug_enabled ⇒ Boolean
The boolean that represents the state of the debug log level.
-
#events_adapter ⇒ Object
The cache adapter to store events in.
-
#events_push_rate ⇒ Integer
The schedule time for events flush after the first one.
-
#events_queue_size ⇒ Integer
The max size of the events queue.
-
#events_uri ⇒ String
The base URL for split events API end points.
-
#features_refresh_rate ⇒ Object
Returns the value of attribute features_refresh_rate.
-
#flag_sets_filter ⇒ Array
Flagsets filter.
-
#impression_listener ⇒ Object
Returns the value of attribute impression_listener.
-
#impression_listener_refresh_rate ⇒ Object
Returns the value of attribute impression_listener_refresh_rate.
-
#impressions_adapter ⇒ Object
The cache adapter to store impressions in.
-
#impressions_bulk_size ⇒ Object
Returns the value of attribute impressions_bulk_size.
-
#impressions_mode ⇒ Object
Returns the value of attribute impressions_mode.
-
#impressions_queue_size ⇒ Integer
How big the impressions queue is before dropping impressions.
-
#impressions_refresh_rate ⇒ Object
Returns the value of attribute impressions_refresh_rate.
-
#ip_addresses_enabled ⇒ Object
Returns the value of attribute ip_addresses_enabled.
-
#labels_enabled ⇒ Boolean
Enable logging labels and sending potentially sensitive information.
-
#language ⇒ Object
Returns the value of attribute language.
-
#localhost_mode ⇒ Object
Returns the value of attribute localhost_mode.
-
#logger ⇒ Logger
The configured logger.
-
#machine_ip ⇒ Object
Returns the value of attribute machine_ip.
-
#machine_name ⇒ Object
Returns the value of attribute machine_name.
-
#max_cache_size ⇒ Object
Returns the value of attribute max_cache_size.
-
#max_key_size ⇒ Object
Returns the value of attribute max_key_size.
-
#mode ⇒ Symbol
The mode SDK will run.
-
#on_demand_fetch_max_retries ⇒ Object
Returns the value of attribute on_demand_fetch_max_retries.
-
#on_demand_fetch_retry_delay_seconds ⇒ Object
Returns the value of attribute on_demand_fetch_retry_delay_seconds.
-
#read_timeout ⇒ Int
The read timeout for network connections in seconds.
-
#redis_namespace ⇒ Object
Returns the value of attribute redis_namespace.
-
#redis_url ⇒ Object
Returns the value of attribute redis_url.
-
#sdk_start_time ⇒ Object
Returns the value of attribute sdk_start_time.
-
#segments_refresh_rate ⇒ Object
Returns the value of attribute segments_refresh_rate.
-
#split_file ⇒ Object
Returns the value of attribute split_file.
-
#split_logger ⇒ SplitLogger
The split logger.
-
#split_validator ⇒ SplitValidator
The split validator.
-
#streaming_enabled ⇒ Object
Returns the value of attribute streaming_enabled.
-
#streaming_reconnect_back_off_base ⇒ Object
Returns the value of attribute streaming_reconnect_back_off_base.
-
#streaming_service_url ⇒ Object
Returns the value of attribute streaming_service_url.
-
#telemetry_adapter ⇒ Object
Returns the value of attribute telemetry_adapter.
-
#telemetry_refresh_rate ⇒ Object
Returns the value of attribute telemetry_refresh_rate.
-
#telemetry_service_url ⇒ Object
Returns the value of attribute telemetry_service_url.
-
#threads ⇒ Object
Returns the value of attribute threads.
-
#transport_debug_enabled ⇒ Boolean
Enable to log the content retrieved from endpoints.
-
#unique_keys_bulk_size ⇒ Object
Returns the value of attribute unique_keys_bulk_size.
-
#unique_keys_cache_max_size ⇒ Object
Returns the value of attribute unique_keys_cache_max_size.
-
#unique_keys_refresh_rate ⇒ Object
Returns the value of attribute unique_keys_refresh_rate.
-
#valid_mode ⇒ Object
Returns the value of attribute valid_mode.
-
#version ⇒ Object
Returns the value of attribute version.
Class Method Summary collapse
-
.cache_ttl ⇒ int
The default cache time to live.
-
.default ⇒ Config
The default split client configuration.
- .default_auth_retry_back_off_base ⇒ Object
- .default_auth_service_url ⇒ Object
-
.default_base_uri ⇒ string
The default base uri for api calls.
-
.default_block_until_ready ⇒ int
The default block until ready value.
-
.default_cache_adapter ⇒ LocalStore
Configuration value for local cache store.
-
.default_connection_timeout ⇒ int
The default connection timeout value.
- .default_counter_refresh_rate(adapter) ⇒ Object
-
.default_debug ⇒ boolean
The default debug value.
- .default_events_push_rate ⇒ Object
- .default_events_queue_size ⇒ Object
- .default_events_uri ⇒ Object
- .default_features_refresh_rate ⇒ Object
- .default_impression_listener_refresh_rate ⇒ Object
- .default_impressions_queue_size ⇒ Object
- .default_impressions_refresh_rate ⇒ Object
- .default_impressions_refresh_rate_optimized ⇒ Object
-
.default_ip_addresses_enabled ⇒ boolean
The default ip addresses enabled value.
-
.default_labels_logging ⇒ boolean
The default labels logging value.
-
.default_logger ⇒ object
The default logger object.
- .default_mode ⇒ Object
- .default_offline_refresh_rate ⇒ Object
- .default_on_demand_fetch_max_retries ⇒ Object
- .default_on_demand_fetch_retry_delay_seconds ⇒ Object
-
.default_read_timeout ⇒ int
The default read timeout value.
- .default_redis_namespace ⇒ Object
- .default_redis_url ⇒ Object
- .default_segments_refresh_rate ⇒ Object
- .default_split_file ⇒ Object
- .default_streaming_enabled ⇒ Object
- .default_streaming_reconnect_back_off_base ⇒ Object
- .default_streaming_service_url ⇒ Object
- .default_telemetry_refresh_rate ⇒ Object
- .default_telemetry_service_url ⇒ Object
- .default_unique_keys_bulk_size(adapter) ⇒ Object
- .default_unique_keys_cache_max_size ⇒ Object
- .default_unique_keys_refresh_rate(adapter) ⇒ Object
- .init_auth_retry_back_off(auth_retry_back_off) ⇒ Object
- .init_cache_adapter(adapter, data_structure, queue_size = nil, redis_url = nil) ⇒ Object
- .init_impressions_refresh_rate(impressions_mode, refresh_rate, default_rate) ⇒ Object
- .init_streaming_reconnect_back_off(streaming_reconnect_back_off) ⇒ Object
- .init_telemetry_adapter(adapter, redis_url) ⇒ Object
- .init_telemetry_refresh_rate(refresh_rate) ⇒ Object
-
.machine_hostname(ip_addresses_enabled, machine_name, adapter) ⇒ string
gets the hostname where the sdk gem is running.
-
.machine_ip(ip_addresses_enabled, ip, adapter) ⇒ string
gets the ip where the sdk gem is running.
- .map_memory_adapter(name, queue_size) ⇒ Object
-
.max_cache_size ⇒ int
The default max cache size.
-
.max_key_size ⇒ int
The default max key size.
- .sanitize_flag_set_filter(flag_sets, validator, adapter, logger) ⇒ Object
-
.transport_debug ⇒ boolean
The default transport_debug_enabled value.
Instance Method Summary collapse
- #consumer? ⇒ Boolean
- #init_impressions_mode(impressions_mode, adapter) ⇒ Object
-
#initialize(opts = {}) ⇒ type
constructor
Constructor for creating custom split client config.
-
#log_found_exception(caller, error) ⇒ void
custom logger of exceptions.
- #standalone? ⇒ Boolean
-
#startup_log ⇒ void
log which cache class was loaded and SDK mode.
Constructor Details
#initialize(opts = {}) ⇒ type
Constructor for creating custom split client config
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/splitclient-rb/split_config.rb', line 29 def initialize(opts = {}) @base_uri = (opts[:base_uri] || SplitConfig.default_base_uri).chomp('/') @events_uri = (opts[:events_uri] || SplitConfig.default_events_uri).chomp('/') @mode = opts[:mode] || SplitConfig.default_mode @redis_url = opts[:redis_url] || SplitConfig.default_redis_url @redis_namespace = opts[:redis_namespace] && opts[:redis_namespace].to_s.length > 0 ? "#{opts[:redis_namespace]}.#{SplitConfig.default_redis_namespace}" : SplitConfig.default_redis_namespace @cache_adapter = SplitConfig.init_cache_adapter( opts[:cache_adapter] || SplitConfig.default_cache_adapter, :map_adapter, nil, @redis_url ) @connection_timeout = opts[:connection_timeout] || SplitConfig.default_connection_timeout @read_timeout = opts[:read_timeout] || SplitConfig.default_read_timeout @logger = opts[:logger] || SplitConfig.default_logger if(opts[:reload_rate]) @features_refresh_rate = opts[:reload_rate] @logger.warn('Localhost mode: reload_rate will be deprecated soon in favor of ' \ 'features_refresh_rate. Take a look in our documentation.' ) else @features_refresh_rate = opts[:features_refresh_rate] || SplitConfig.default_features_refresh_rate end @segments_refresh_rate = opts[:segments_refresh_rate] || SplitConfig.default_segments_refresh_rate @impressions_mode = init_impressions_mode(opts[:impressions_mode], opts[:cache_adapter]) @impressions_refresh_rate = SplitConfig.init_impressions_refresh_rate(@impressions_mode, opts[:impressions_refresh_rate], SplitConfig.default_impressions_refresh_rate) @impressions_queue_size = opts[:impressions_queue_size] || SplitConfig.default_impressions_queue_size @impressions_adapter = SplitConfig.init_cache_adapter( opts[:cache_adapter] || SplitConfig.default_cache_adapter, :queue_adapter, @impressions_queue_size, @redis_url ) #Safeguard for users of older SDK versions. @impressions_bulk_size = opts[:impressions_bulk_size] || @impressions_queue_size > 0 ? @impressions_queue_size : 0 @debug_enabled = opts[:debug_enabled] || SplitConfig.default_debug @transport_debug_enabled = opts[:transport_debug_enabled] || SplitConfig.default_debug @block_until_ready = SplitConfig.default_block_until_ready @ip_addresses_enabled = opts[:ip_addresses_enabled].nil? ? SplitConfig.default_ip_addresses_enabled : opts[:ip_addresses_enabled] @machine_name = SplitConfig.machine_hostname(@ip_addresses_enabled, opts[:machine_name], opts[:cache_adapter] || SplitConfig.default_cache_adapter) @machine_ip = SplitConfig.machine_ip(@ip_addresses_enabled, opts[:machine_ip], opts[:cache_adapter] || SplitConfig.default_cache_adapter) @cache_ttl = opts[:cache_ttl] || SplitConfig.cache_ttl @max_cache_size = opts[:max_cache_size] || SplitConfig.max_cache_size @language = opts[:language] || 'ruby' @version = opts[:version] || SplitIoClient::VERSION @labels_enabled = opts[:labels_enabled].nil? ? SplitConfig.default_labels_logging : opts[:labels_enabled] @impression_listener = opts[:impression_listener] @impression_listener_refresh_rate = opts[:impression_listener_refresh_rate] || SplitConfig.default_impression_listener_refresh_rate @max_key_size = SplitConfig.max_key_size @threads = {} @events_push_rate = opts[:events_push_rate] || SplitConfig.default_events_push_rate @events_queue_size = opts[:events_queue_size] || SplitConfig.default_events_queue_size @events_adapter = SplitConfig.init_cache_adapter( opts[:cache_adapter] || SplitConfig.default_cache_adapter, :queue_adapter, @events_queue_size, @redis_url ) @telemetry_adapter = SplitConfig.init_telemetry_adapter( opts[:cache_adapter] || SplitConfig.default_cache_adapter, @redis_url ) @split_file = opts[:split_file] || SplitConfig.default_split_file @valid_mode = true @split_logger = SplitIoClient::SplitLogger.new(self) @split_validator = SplitIoClient::Validators.new(self) @localhost_mode = opts[:localhost_mode] @streaming_enabled = consumer? ? false : (opts[:streaming_enabled].nil? ? SplitConfig.default_streaming_enabled : opts[:streaming_enabled]) @streaming_service_url = opts[:streaming_service_url] || SplitConfig.default_streaming_service_url @auth_service_url = opts[:auth_service_url] || SplitConfig.default_auth_service_url @auth_retry_back_off_base = SplitConfig.init_auth_retry_back_off(opts[:auth_retry_back_off_base] || SplitConfig.default_auth_retry_back_off_base) @streaming_reconnect_back_off_base = SplitConfig.init_streaming_reconnect_back_off(opts[:streaming_reconnect_back_off_base] || SplitConfig.default_streaming_reconnect_back_off_base) @telemetry_refresh_rate = SplitConfig.init_telemetry_refresh_rate(opts[:telemetry_refresh_rate]) @telemetry_service_url = opts[:telemetry_service_url] || SplitConfig.default_telemetry_service_url @unique_keys_refresh_rate = SplitConfig.default_unique_keys_refresh_rate(@cache_adapter) @unique_keys_cache_max_size = SplitConfig.default_unique_keys_cache_max_size @unique_keys_bulk_size = SplitConfig.default_unique_keys_bulk_size(@cache_adapter) @counter_refresh_rate = SplitConfig.default_counter_refresh_rate(@cache_adapter) @sdk_start_time = Time.now.to_f @on_demand_fetch_retry_delay_seconds = SplitConfig.default_on_demand_fetch_retry_delay_seconds @on_demand_fetch_max_retries = SplitConfig.default_on_demand_fetch_max_retries @flag_sets_filter = SplitConfig.sanitize_flag_set_filter(opts[:flag_sets_filter], @split_validator, opts[:cache_adapter], @logger) startup_log end |
Instance Attribute Details
#auth_retry_back_off_base ⇒ Object
Returns the value of attribute auth_retry_back_off_base.
273 274 275 |
# File 'lib/splitclient-rb/split_config.rb', line 273 def auth_retry_back_off_base @auth_retry_back_off_base end |
#auth_service_url ⇒ Object
Returns the value of attribute auth_service_url.
271 272 273 |
# File 'lib/splitclient-rb/split_config.rb', line 271 def auth_service_url @auth_service_url end |
#base_uri ⇒ String
The base URL for split API end points
133 134 135 |
# File 'lib/splitclient-rb/split_config.rb', line 133 def base_uri @base_uri end |
#block_until_ready ⇒ Integer
The number of seconds to wait for SDK readiness or false to disable waiting
219 220 221 |
# File 'lib/splitclient-rb/split_config.rb', line 219 def block_until_ready @block_until_ready end |
#cache_adapter ⇒ Object
The cache adapter to store splits/segments in
156 157 158 |
# File 'lib/splitclient-rb/split_config.rb', line 156 def cache_adapter @cache_adapter end |
#cache_ttl ⇒ Object
Returns the value of attribute cache_ttl.
224 225 226 |
# File 'lib/splitclient-rb/split_config.rb', line 224 def cache_ttl @cache_ttl end |
#connection_timeout ⇒ Int
The connection timeout for network connections in seconds.
174 175 176 |
# File 'lib/splitclient-rb/split_config.rb', line 174 def connection_timeout @connection_timeout end |
#counter_refresh_rate ⇒ Object
Returns the value of attribute counter_refresh_rate.
298 299 300 |
# File 'lib/splitclient-rb/split_config.rb', line 298 def counter_refresh_rate @counter_refresh_rate end |
#debug_enabled ⇒ Boolean
The boolean that represents the state of the debug log level
201 202 203 |
# File 'lib/splitclient-rb/split_config.rb', line 201 def debug_enabled @debug_enabled end |
#events_adapter ⇒ Object
The cache adapter to store events in
168 169 170 |
# File 'lib/splitclient-rb/split_config.rb', line 168 def events_adapter @events_adapter end |
#events_push_rate ⇒ Integer
The schedule time for events flush after the first one
257 258 259 |
# File 'lib/splitclient-rb/split_config.rb', line 257 def events_push_rate @events_push_rate end |
#events_queue_size ⇒ Integer
The max size of the events queue
263 264 265 |
# File 'lib/splitclient-rb/split_config.rb', line 263 def events_queue_size @events_queue_size end |
#events_uri ⇒ String
The base URL for split events API end points
139 140 141 |
# File 'lib/splitclient-rb/split_config.rb', line 139 def events_uri @events_uri end |
#features_refresh_rate ⇒ Object
Returns the value of attribute features_refresh_rate.
232 233 234 |
# File 'lib/splitclient-rb/split_config.rb', line 232 def features_refresh_rate @features_refresh_rate end |
#flag_sets_filter ⇒ Array
Flagsets filter
304 305 306 |
# File 'lib/splitclient-rb/split_config.rb', line 304 def flag_sets_filter @flag_sets_filter end |
#impression_listener ⇒ Object
Returns the value of attribute impression_listener.
236 237 238 |
# File 'lib/splitclient-rb/split_config.rb', line 236 def impression_listener @impression_listener end |
#impression_listener_refresh_rate ⇒ Object
Returns the value of attribute impression_listener_refresh_rate.
237 238 239 |
# File 'lib/splitclient-rb/split_config.rb', line 237 def impression_listener_refresh_rate @impression_listener_refresh_rate end |
#impressions_adapter ⇒ Object
The cache adapter to store impressions in
162 163 164 |
# File 'lib/splitclient-rb/split_config.rb', line 162 def impressions_adapter @impressions_adapter end |
#impressions_bulk_size ⇒ Object
Returns the value of attribute impressions_bulk_size.
244 245 246 |
# File 'lib/splitclient-rb/split_config.rb', line 244 def impressions_bulk_size @impressions_bulk_size end |
#impressions_mode ⇒ Object
Returns the value of attribute impressions_mode.
281 282 283 |
# File 'lib/splitclient-rb/split_config.rb', line 281 def impressions_mode @impressions_mode end |
#impressions_queue_size ⇒ Integer
How big the impressions queue is before dropping impressions
243 244 245 |
# File 'lib/splitclient-rb/split_config.rb', line 243 def impressions_queue_size @impressions_queue_size end |
#impressions_refresh_rate ⇒ Object
Returns the value of attribute impressions_refresh_rate.
234 235 236 |
# File 'lib/splitclient-rb/split_config.rb', line 234 def impressions_refresh_rate @impressions_refresh_rate end |
#ip_addresses_enabled ⇒ Object
Returns the value of attribute ip_addresses_enabled.
269 270 271 |
# File 'lib/splitclient-rb/split_config.rb', line 269 def ip_addresses_enabled @ip_addresses_enabled end |
#labels_enabled ⇒ Boolean
Enable logging labels and sending potentially sensitive information
213 214 215 |
# File 'lib/splitclient-rb/split_config.rb', line 213 def labels_enabled @labels_enabled end |
#language ⇒ Object
Returns the value of attribute language.
229 230 231 |
# File 'lib/splitclient-rb/split_config.rb', line 229 def language @language end |
#localhost_mode ⇒ Object
Returns the value of attribute localhost_mode.
267 268 269 |
# File 'lib/splitclient-rb/split_config.rb', line 267 def localhost_mode @localhost_mode end |
#logger ⇒ Logger
The configured logger. The client library uses the log to print warning and error messages.
181 182 183 |
# File 'lib/splitclient-rb/split_config.rb', line 181 def logger @logger end |
#machine_ip ⇒ Object
Returns the value of attribute machine_ip.
221 222 223 |
# File 'lib/splitclient-rb/split_config.rb', line 221 def machine_ip @machine_ip end |
#machine_name ⇒ Object
Returns the value of attribute machine_name.
222 223 224 |
# File 'lib/splitclient-rb/split_config.rb', line 222 def machine_name @machine_name end |
#max_cache_size ⇒ Object
Returns the value of attribute max_cache_size.
225 226 227 |
# File 'lib/splitclient-rb/split_config.rb', line 225 def max_cache_size @max_cache_size end |
#max_key_size ⇒ Object
Returns the value of attribute max_key_size.
227 228 229 |
# File 'lib/splitclient-rb/split_config.rb', line 227 def max_key_size @max_key_size end |
#mode ⇒ Symbol
The mode SDK will run
145 146 147 |
# File 'lib/splitclient-rb/split_config.rb', line 145 def mode @mode end |
#on_demand_fetch_max_retries ⇒ Object
Returns the value of attribute on_demand_fetch_max_retries.
292 293 294 |
# File 'lib/splitclient-rb/split_config.rb', line 292 def on_demand_fetch_max_retries @on_demand_fetch_max_retries end |
#on_demand_fetch_retry_delay_seconds ⇒ Object
Returns the value of attribute on_demand_fetch_retry_delay_seconds.
291 292 293 |
# File 'lib/splitclient-rb/split_config.rb', line 291 def on_demand_fetch_retry_delay_seconds @on_demand_fetch_retry_delay_seconds end |
#read_timeout ⇒ Int
The read timeout for network connections in seconds.
150 151 152 |
# File 'lib/splitclient-rb/split_config.rb', line 150 def read_timeout @read_timeout end |
#redis_namespace ⇒ Object
Returns the value of attribute redis_namespace.
247 248 249 |
# File 'lib/splitclient-rb/split_config.rb', line 247 def redis_namespace @redis_namespace end |
#redis_url ⇒ Object
Returns the value of attribute redis_url.
246 247 248 |
# File 'lib/splitclient-rb/split_config.rb', line 246 def redis_url @redis_url end |
#sdk_start_time ⇒ Object
Returns the value of attribute sdk_start_time.
289 290 291 |
# File 'lib/splitclient-rb/split_config.rb', line 289 def sdk_start_time @sdk_start_time end |
#segments_refresh_rate ⇒ Object
Returns the value of attribute segments_refresh_rate.
233 234 235 |
# File 'lib/splitclient-rb/split_config.rb', line 233 def segments_refresh_rate @segments_refresh_rate end |
#split_file ⇒ Object
Returns the value of attribute split_file.
265 266 267 |
# File 'lib/splitclient-rb/split_config.rb', line 265 def split_file @split_file end |
#split_logger ⇒ SplitLogger
The split logger. The client library uses the split logger to use common functions around the logger
188 189 190 |
# File 'lib/splitclient-rb/split_config.rb', line 188 def split_logger @split_logger end |
#split_validator ⇒ SplitValidator
The split validator. The client library uses the split validator to validate inputs accross the sdk
195 196 197 |
# File 'lib/splitclient-rb/split_config.rb', line 195 def split_validator @split_validator end |
#streaming_enabled ⇒ Object
Returns the value of attribute streaming_enabled.
279 280 281 |
# File 'lib/splitclient-rb/split_config.rb', line 279 def streaming_enabled @streaming_enabled end |
#streaming_reconnect_back_off_base ⇒ Object
Returns the value of attribute streaming_reconnect_back_off_base.
277 278 279 |
# File 'lib/splitclient-rb/split_config.rb', line 277 def streaming_reconnect_back_off_base @streaming_reconnect_back_off_base end |
#streaming_service_url ⇒ Object
Returns the value of attribute streaming_service_url.
275 276 277 |
# File 'lib/splitclient-rb/split_config.rb', line 275 def streaming_service_url @streaming_service_url end |
#telemetry_adapter ⇒ Object
Returns the value of attribute telemetry_adapter.
283 284 285 |
# File 'lib/splitclient-rb/split_config.rb', line 283 def telemetry_adapter @telemetry_adapter end |
#telemetry_refresh_rate ⇒ Object
Returns the value of attribute telemetry_refresh_rate.
285 286 287 |
# File 'lib/splitclient-rb/split_config.rb', line 285 def telemetry_refresh_rate @telemetry_refresh_rate end |
#telemetry_service_url ⇒ Object
Returns the value of attribute telemetry_service_url.
287 288 289 |
# File 'lib/splitclient-rb/split_config.rb', line 287 def telemetry_service_url @telemetry_service_url end |
#threads ⇒ Object
Returns the value of attribute threads.
249 250 251 |
# File 'lib/splitclient-rb/split_config.rb', line 249 def threads @threads end |
#transport_debug_enabled ⇒ Boolean
Enable to log the content retrieved from endpoints
207 208 209 |
# File 'lib/splitclient-rb/split_config.rb', line 207 def transport_debug_enabled @transport_debug_enabled end |
#unique_keys_bulk_size ⇒ Object
Returns the value of attribute unique_keys_bulk_size.
296 297 298 |
# File 'lib/splitclient-rb/split_config.rb', line 296 def unique_keys_bulk_size @unique_keys_bulk_size end |
#unique_keys_cache_max_size ⇒ Object
Returns the value of attribute unique_keys_cache_max_size.
295 296 297 |
# File 'lib/splitclient-rb/split_config.rb', line 295 def unique_keys_cache_max_size @unique_keys_cache_max_size end |
#unique_keys_refresh_rate ⇒ Object
Returns the value of attribute unique_keys_refresh_rate.
294 295 296 |
# File 'lib/splitclient-rb/split_config.rb', line 294 def unique_keys_refresh_rate @unique_keys_refresh_rate end |
#valid_mode ⇒ Object
Returns the value of attribute valid_mode.
251 252 253 |
# File 'lib/splitclient-rb/split_config.rb', line 251 def valid_mode @valid_mode end |
#version ⇒ Object
Returns the value of attribute version.
230 231 232 |
# File 'lib/splitclient-rb/split_config.rb', line 230 def version @version end |
Class Method Details
.cache_ttl ⇒ int
The default cache time to live
598 599 600 |
# File 'lib/splitclient-rb/split_config.rb', line 598 def self.cache_ttl 5 end |
.default ⇒ Config
The default split client configuration
379 380 381 |
# File 'lib/splitclient-rb/split_config.rb', line 379 def self.default SplitConfig.new end |
.default_auth_retry_back_off_base ⇒ Object
359 360 361 |
# File 'lib/splitclient-rb/split_config.rb', line 359 def self.default_auth_retry_back_off_base 1 end |
.default_auth_service_url ⇒ Object
355 356 357 |
# File 'lib/splitclient-rb/split_config.rb', line 355 def self.default_auth_service_url 'https://auth.split.io/api/v2/auth' end |
.default_base_uri ⇒ string
The default base uri for api calls
387 388 389 |
# File 'lib/splitclient-rb/split_config.rb', line 387 def self.default_base_uri 'https://sdk.split.io/api/' end |
.default_block_until_ready ⇒ int
The default block until ready value
574 575 576 |
# File 'lib/splitclient-rb/split_config.rb', line 574 def self.default_block_until_ready 15 end |
.default_cache_adapter ⇒ LocalStore
Returns configuration value for local cache store.
439 440 441 |
# File 'lib/splitclient-rb/split_config.rb', line 439 def self.default_cache_adapter :memory end |
.default_connection_timeout ⇒ int
The default connection timeout value
455 456 457 |
# File 'lib/splitclient-rb/split_config.rb', line 455 def self.default_connection_timeout 5 end |
.default_counter_refresh_rate(adapter) ⇒ Object
306 307 308 309 310 |
# File 'lib/splitclient-rb/split_config.rb', line 306 def self.default_counter_refresh_rate(adapter) return 300 if adapter == :redis # Send bulk impressions count - Refresh rate: 5 min. 1800 # Send bulk impressions count - Refresh rate: 30 min. end |
.default_debug ⇒ boolean
The default debug value
550 551 552 |
# File 'lib/splitclient-rb/split_config.rb', line 550 def self.default_debug false end |
.default_events_push_rate ⇒ Object
483 484 485 |
# File 'lib/splitclient-rb/split_config.rb', line 483 def self.default_events_push_rate 60 end |
.default_events_queue_size ⇒ Object
487 488 489 |
# File 'lib/splitclient-rb/split_config.rb', line 487 def self.default_events_queue_size 500 end |
.default_events_uri ⇒ Object
391 392 393 |
# File 'lib/splitclient-rb/split_config.rb', line 391 def self.default_events_uri 'https://events.split.io/api/' end |
.default_features_refresh_rate ⇒ Object
459 460 461 |
# File 'lib/splitclient-rb/split_config.rb', line 459 def self.default_features_refresh_rate 60 end |
.default_impression_listener_refresh_rate ⇒ Object
475 476 477 |
# File 'lib/splitclient-rb/split_config.rb', line 475 def self.default_impression_listener_refresh_rate 0 end |
.default_impressions_queue_size ⇒ Object
479 480 481 |
# File 'lib/splitclient-rb/split_config.rb', line 479 def self.default_impressions_queue_size 5000 end |
.default_impressions_refresh_rate ⇒ Object
467 468 469 |
# File 'lib/splitclient-rb/split_config.rb', line 467 def self.default_impressions_refresh_rate 60 end |
.default_impressions_refresh_rate_optimized ⇒ Object
471 472 473 |
# File 'lib/splitclient-rb/split_config.rb', line 471 def self.default_impressions_refresh_rate_optimized 300 end |
.default_ip_addresses_enabled ⇒ boolean
The default ip addresses enabled value
582 583 584 |
# File 'lib/splitclient-rb/split_config.rb', line 582 def self.default_ip_addresses_enabled true end |
.default_labels_logging ⇒ boolean
The default labels logging value
558 559 560 |
# File 'lib/splitclient-rb/split_config.rb', line 558 def self.default_labels_logging true end |
.default_logger ⇒ object
The default logger object
536 537 538 539 540 541 542 543 544 |
# File 'lib/splitclient-rb/split_config.rb', line 536 def self.default_logger if defined?(Rails) && Rails.logger Rails.logger elsif ENV['SPLITCLIENT_ENV'] == 'test' Logger.new('/dev/null') else Logger.new($stdout) end end |
.default_mode ⇒ Object
434 435 436 |
# File 'lib/splitclient-rb/split_config.rb', line 434 def self.default_mode :standalone end |
.default_offline_refresh_rate ⇒ Object
519 520 521 |
# File 'lib/splitclient-rb/split_config.rb', line 519 def self.default_offline_refresh_rate 5 end |
.default_on_demand_fetch_max_retries ⇒ Object
316 317 318 |
# File 'lib/splitclient-rb/split_config.rb', line 316 def self.default_on_demand_fetch_max_retries 10 end |
.default_on_demand_fetch_retry_delay_seconds ⇒ Object
312 313 314 |
# File 'lib/splitclient-rb/split_config.rb', line 312 def self.default_on_demand_fetch_retry_delay_seconds 0.05 end |
.default_read_timeout ⇒ int
The default read timeout value
447 448 449 |
# File 'lib/splitclient-rb/split_config.rb', line 447 def self.default_read_timeout 5 end |
.default_redis_namespace ⇒ Object
566 567 568 |
# File 'lib/splitclient-rb/split_config.rb', line 566 def self.default_redis_namespace 'SPLITIO' end |
.default_redis_url ⇒ Object
562 563 564 |
# File 'lib/splitclient-rb/split_config.rb', line 562 def self.default_redis_url 'redis://127.0.0.1:6379/0' end |
.default_segments_refresh_rate ⇒ Object
463 464 465 |
# File 'lib/splitclient-rb/split_config.rb', line 463 def self.default_segments_refresh_rate 60 end |
.default_split_file ⇒ Object
515 516 517 |
# File 'lib/splitclient-rb/split_config.rb', line 515 def self.default_split_file File.join(Dir.home, '.split') end |
.default_streaming_enabled ⇒ Object
347 348 349 |
# File 'lib/splitclient-rb/split_config.rb', line 347 def self.default_streaming_enabled true end |
.default_streaming_reconnect_back_off_base ⇒ Object
363 364 365 |
# File 'lib/splitclient-rb/split_config.rb', line 363 def self.default_streaming_reconnect_back_off_base 1 end |
.default_streaming_service_url ⇒ Object
351 352 353 |
# File 'lib/splitclient-rb/split_config.rb', line 351 def self.default_streaming_service_url 'https://streaming.split.io/event-stream' end |
.default_telemetry_refresh_rate ⇒ Object
491 492 493 |
# File 'lib/splitclient-rb/split_config.rb', line 491 def self.default_telemetry_refresh_rate 3600 end |
.default_telemetry_service_url ⇒ Object
511 512 513 |
# File 'lib/splitclient-rb/split_config.rb', line 511 def self.default_telemetry_service_url 'https://telemetry.split.io/api/v1' end |
.default_unique_keys_bulk_size(adapter) ⇒ Object
505 506 507 508 509 |
# File 'lib/splitclient-rb/split_config.rb', line 505 def self.default_unique_keys_bulk_size(adapter) return 2000 if adapter == :redis 5000 end |
.default_unique_keys_cache_max_size ⇒ Object
501 502 503 |
# File 'lib/splitclient-rb/split_config.rb', line 501 def self.default_unique_keys_cache_max_size 30000 end |
.default_unique_keys_refresh_rate(adapter) ⇒ Object
495 496 497 498 499 |
# File 'lib/splitclient-rb/split_config.rb', line 495 def self.default_unique_keys_refresh_rate(adapter) return 300 if adapter == :redis 900 end |
.init_auth_retry_back_off(auth_retry_back_off) ⇒ Object
367 368 369 |
# File 'lib/splitclient-rb/split_config.rb', line 367 def self.init_auth_retry_back_off(auth_retry_back_off) auth_retry_back_off < 1 ? SplitConfig.default_auth_retry_back_off_base : auth_retry_back_off end |
.init_cache_adapter(adapter, data_structure, queue_size = nil, redis_url = nil) ⇒ Object
395 396 397 398 399 400 401 402 403 404 405 406 407 408 |
# File 'lib/splitclient-rb/split_config.rb', line 395 def self.init_cache_adapter(adapter, data_structure, queue_size = nil, redis_url = nil) case adapter when :memory SplitIoClient::Cache::Adapters::MemoryAdapter.new(map_memory_adapter(data_structure, queue_size)) when :redis begin require 'redis' rescue LoadError fail StandardError, 'To use Redis as a cache adapter you must include it in your Gemfile' end SplitIoClient::Cache::Adapters::RedisAdapter.new(redis_url) end end |
.init_impressions_refresh_rate(impressions_mode, refresh_rate, default_rate) ⇒ Object
335 336 337 338 339 |
# File 'lib/splitclient-rb/split_config.rb', line 335 def self.init_impressions_refresh_rate(impressions_mode, refresh_rate, default_rate) return (refresh_rate.nil? || refresh_rate <= 0 ? default_rate : refresh_rate) if impressions_mode == :debug return refresh_rate.nil? || refresh_rate <= 0 ? SplitConfig.default_impressions_refresh_rate_optimized : [default_rate, refresh_rate].max end |
.init_streaming_reconnect_back_off(streaming_reconnect_back_off) ⇒ Object
371 372 373 |
# File 'lib/splitclient-rb/split_config.rb', line 371 def self.init_streaming_reconnect_back_off(streaming_reconnect_back_off) streaming_reconnect_back_off < 1 ? SplitConfig.default_streaming_reconnect_back_off_base : streaming_reconnect_back_off end |
.init_telemetry_adapter(adapter, redis_url) ⇒ Object
410 411 412 413 414 415 416 417 418 419 420 421 422 423 |
# File 'lib/splitclient-rb/split_config.rb', line 410 def self.init_telemetry_adapter(adapter, redis_url) case adapter when :memory Telemetry::Storages::Memory.new when :redis begin require 'redis' rescue LoadError fail StandardError, 'To use Redis as a cache adapter you must include it in your Gemfile' end SplitIoClient::Cache::Adapters::RedisAdapter.new(redis_url) end end |
.init_telemetry_refresh_rate(refresh_rate) ⇒ Object
341 342 343 344 345 |
# File 'lib/splitclient-rb/split_config.rb', line 341 def self.init_telemetry_refresh_rate(refresh_rate) return SplitConfig.default_telemetry_refresh_rate if refresh_rate.nil? || refresh_rate < 60 refresh_rate end |
.machine_hostname(ip_addresses_enabled, machine_name, adapter) ⇒ string
gets the hostname where the sdk gem is running
652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 |
# File 'lib/splitclient-rb/split_config.rb', line 652 def self.machine_hostname(ip_addresses_enabled, machine_name, adapter) if ip_addresses_enabled begin return machine_name || Socket.gethostname rescue return 'unknown'.freeze end else case adapter when :redis return 'NA'.freeze end end return ''.freeze end |
.machine_ip(ip_addresses_enabled, ip, adapter) ⇒ string
gets the ip where the sdk gem is running
673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 |
# File 'lib/splitclient-rb/split_config.rb', line 673 def self.machine_ip(ip_addresses_enabled, ip, adapter) if ip_addresses_enabled begin return ip unless ip.nil? || ip.to_s.empty? loopback_ip = Socket.ip_address_list.find { |ip| ip.ipv4_loopback? } private_ip = Socket.ip_address_list.find { |ip| ip.ipv4_private? } addr_info = private_ip || loopback_ip return addr_info.ip_address rescue return 'unknown'.freeze end else case adapter when :redis return 'NA'.freeze end end return ''.freeze end |
.map_memory_adapter(name, queue_size) ⇒ Object
425 426 427 428 429 430 431 432 |
# File 'lib/splitclient-rb/split_config.rb', line 425 def self.map_memory_adapter(name, queue_size) case name when :map_adapter SplitIoClient::Cache::Adapters::MemoryAdapters::MapAdapter.new when :queue_adapter SplitIoClient::Cache::Adapters::MemoryAdapters::QueueAdapter.new(queue_size) end end |
.max_cache_size ⇒ int
The default max cache size
605 606 607 |
# File 'lib/splitclient-rb/split_config.rb', line 605 def self.max_cache_size 500 end |
.max_key_size ⇒ int
The default max key size
612 613 614 |
# File 'lib/splitclient-rb/split_config.rb', line 612 def self.max_key_size 250 end |
.sanitize_flag_set_filter(flag_sets, validator, adapter, logger) ⇒ Object
523 524 525 526 527 528 529 530 |
# File 'lib/splitclient-rb/split_config.rb', line 523 def self.sanitize_flag_set_filter(flag_sets, validator, adapter, logger) return [] if flag_sets.nil? if adapter == :redis logger.warn("config: : flag_sets_filter is not applicable for Consumer modes where the SDK does not keep rollout data in sync. FlagSet filter was discarded") return [] end return validator.valid_flag_sets(:config, flag_sets) end |
.transport_debug ⇒ boolean
The default transport_debug_enabled value
590 591 592 |
# File 'lib/splitclient-rb/split_config.rb', line 590 def self.transport_debug false end |
Instance Method Details
#consumer? ⇒ Boolean
644 645 646 |
# File 'lib/splitclient-rb/split_config.rb', line 644 def consumer? @mode.equal?(:consumer) end |
#init_impressions_mode(impressions_mode, adapter) ⇒ Object
320 321 322 323 324 325 326 327 328 329 330 331 332 333 |
# File 'lib/splitclient-rb/split_config.rb', line 320 def init_impressions_mode(impressions_mode, adapter) case impressions_mode when :optimized return :optimized when :none return :none when :debug return :debug else default = adapter == :redis ? :debug : :optimized @logger.error("You passed an invalid impressions_mode, impressions_mode should be one of the following values: :debug, :optimized or :none. Defaulting to #{default} mode") unless impressions_mode.nil? return default end end |
#log_found_exception(caller, error) ⇒ void
This method returns an undefined value.
custom logger of exceptions
620 621 622 623 624 625 626 627 |
# File 'lib/splitclient-rb/split_config.rb', line 620 def log_found_exception(caller, error) = '' << "[splitclient-rb] Unexpected exception in #{caller}: #{error.inspect} #{error}" << "\n\t#{error.backtrace.join("\n\t")}" if @debug_enabled @logger.warn() end |
#standalone? ⇒ Boolean
640 641 642 |
# File 'lib/splitclient-rb/split_config.rb', line 640 def standalone? @mode.equal?(:standalone) end |
#startup_log ⇒ void
This method returns an undefined value.
log which cache class was loaded and SDK mode
633 634 635 636 637 638 |
# File 'lib/splitclient-rb/split_config.rb', line 633 def startup_log return if ENV['SPLITCLIENT_ENV'] == 'test' @logger.info("Loaded Ruby SDK v#{VERSION} in the #{@mode} mode") @logger.info("Loaded cache class: #{@cache_adapter.class}") end |