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
-
#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.
-
#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.
-
#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_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.
-
#metrics_adapter ⇒ Symbol
The cache adapter to store metrics in.
-
#metrics_refresh_rate ⇒ Object
Returns the value of attribute metrics_refresh_rate.
-
#mode ⇒ Symbol
The mode SDK will run.
-
#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.
-
#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.
-
#threads ⇒ Object
Returns the value of attribute threads.
-
#transport_debug_enabled ⇒ Boolean
Enable to log the content retrieved from endpoints.
-
#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_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_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_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_metrics_adapter ⇒ Object
- .default_metrics_refresh_rate ⇒ Object
- .default_mode ⇒ Object
- .default_offline_refresh_rate ⇒ 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
- .init_cache_adapter(adapter, data_structure, queue_size = nil, redis_url = nil) ⇒ 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.
-
.transport_debug ⇒ boolean
The default transport_debug_enabled value.
Instance Method Summary collapse
- #consumer? ⇒ Boolean
-
#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
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 |
# File 'lib/splitclient-rb/split_config.rb', line 30 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 @metrics_refresh_rate = opts[:metrics_refresh_rate] || SplitConfig.default_metrics_refresh_rate @impressions_refresh_rate = 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 @metrics_adapter = SplitConfig.init_cache_adapter( opts[:cache_adapter] || SplitConfig.default_cache_adapter, :map_adapter, nil, @redis_url ) @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 ) @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] startup_log end |
Instance Attribute Details
#base_uri ⇒ String
The base URL for split API end points
112 113 114 |
# File 'lib/splitclient-rb/split_config.rb', line 112 def base_uri @base_uri end |
#block_until_ready ⇒ Integer
The number of seconds to wait for SDK readiness or false to disable waiting
205 206 207 |
# File 'lib/splitclient-rb/split_config.rb', line 205 def block_until_ready @block_until_ready end |
#cache_adapter ⇒ Object
The cache adapter to store splits/segments in
135 136 137 |
# File 'lib/splitclient-rb/split_config.rb', line 135 def cache_adapter @cache_adapter end |
#cache_ttl ⇒ Object
Returns the value of attribute cache_ttl.
210 211 212 |
# File 'lib/splitclient-rb/split_config.rb', line 210 def cache_ttl @cache_ttl end |
#connection_timeout ⇒ Int
The connection timeout for network connections in seconds.
159 160 161 |
# File 'lib/splitclient-rb/split_config.rb', line 159 def connection_timeout @connection_timeout end |
#debug_enabled ⇒ Boolean
The boolean that represents the state of the debug log level
187 188 189 |
# File 'lib/splitclient-rb/split_config.rb', line 187 def debug_enabled @debug_enabled end |
#events_adapter ⇒ Object
The cache adapter to store events in
153 154 155 |
# File 'lib/splitclient-rb/split_config.rb', line 153 def events_adapter @events_adapter end |
#events_push_rate ⇒ Integer
The schedule time for events flush after the first one
244 245 246 |
# File 'lib/splitclient-rb/split_config.rb', line 244 def events_push_rate @events_push_rate end |
#events_queue_size ⇒ Integer
The max size of the events queue
250 251 252 |
# File 'lib/splitclient-rb/split_config.rb', line 250 def events_queue_size @events_queue_size end |
#events_uri ⇒ String
The base URL for split events API end points
118 119 120 |
# File 'lib/splitclient-rb/split_config.rb', line 118 def events_uri @events_uri end |
#features_refresh_rate ⇒ Object
Returns the value of attribute features_refresh_rate.
218 219 220 |
# File 'lib/splitclient-rb/split_config.rb', line 218 def features_refresh_rate @features_refresh_rate end |
#impression_listener ⇒ Object
Returns the value of attribute impression_listener.
223 224 225 |
# File 'lib/splitclient-rb/split_config.rb', line 223 def impression_listener @impression_listener end |
#impression_listener_refresh_rate ⇒ Object
Returns the value of attribute impression_listener_refresh_rate.
224 225 226 |
# File 'lib/splitclient-rb/split_config.rb', line 224 def impression_listener_refresh_rate @impression_listener_refresh_rate end |
#impressions_adapter ⇒ Object
The cache adapter to store impressions in
141 142 143 |
# File 'lib/splitclient-rb/split_config.rb', line 141 def impressions_adapter @impressions_adapter end |
#impressions_bulk_size ⇒ Object
Returns the value of attribute impressions_bulk_size.
231 232 233 |
# File 'lib/splitclient-rb/split_config.rb', line 231 def impressions_bulk_size @impressions_bulk_size end |
#impressions_queue_size ⇒ Integer
How big the impressions queue is before dropping impressions
230 231 232 |
# File 'lib/splitclient-rb/split_config.rb', line 230 def impressions_queue_size @impressions_queue_size end |
#impressions_refresh_rate ⇒ Object
Returns the value of attribute impressions_refresh_rate.
221 222 223 |
# File 'lib/splitclient-rb/split_config.rb', line 221 def impressions_refresh_rate @impressions_refresh_rate end |
#ip_addresses_enabled ⇒ Object
Returns the value of attribute ip_addresses_enabled.
256 257 258 |
# File 'lib/splitclient-rb/split_config.rb', line 256 def ip_addresses_enabled @ip_addresses_enabled end |
#labels_enabled ⇒ Boolean
Enable logging labels and sending potentially sensitive information
199 200 201 |
# File 'lib/splitclient-rb/split_config.rb', line 199 def labels_enabled @labels_enabled end |
#language ⇒ Object
Returns the value of attribute language.
215 216 217 |
# File 'lib/splitclient-rb/split_config.rb', line 215 def language @language end |
#localhost_mode ⇒ Object
Returns the value of attribute localhost_mode.
254 255 256 |
# File 'lib/splitclient-rb/split_config.rb', line 254 def localhost_mode @localhost_mode end |
#logger ⇒ Logger
The configured logger. The client library uses the log to print warning and error messages.
166 167 168 |
# File 'lib/splitclient-rb/split_config.rb', line 166 def logger @logger end |
#machine_ip ⇒ Object
Returns the value of attribute machine_ip.
207 208 209 |
# File 'lib/splitclient-rb/split_config.rb', line 207 def machine_ip @machine_ip end |
#machine_name ⇒ Object
Returns the value of attribute machine_name.
208 209 210 |
# File 'lib/splitclient-rb/split_config.rb', line 208 def machine_name @machine_name end |
#max_cache_size ⇒ Object
Returns the value of attribute max_cache_size.
211 212 213 |
# File 'lib/splitclient-rb/split_config.rb', line 211 def max_cache_size @max_cache_size end |
#max_key_size ⇒ Object
Returns the value of attribute max_key_size.
213 214 215 |
# File 'lib/splitclient-rb/split_config.rb', line 213 def max_key_size @max_key_size end |
#metrics_adapter ⇒ Symbol
The cache adapter to store metrics in
147 148 149 |
# File 'lib/splitclient-rb/split_config.rb', line 147 def metrics_adapter @metrics_adapter end |
#metrics_refresh_rate ⇒ Object
Returns the value of attribute metrics_refresh_rate.
220 221 222 |
# File 'lib/splitclient-rb/split_config.rb', line 220 def metrics_refresh_rate @metrics_refresh_rate end |
#mode ⇒ Symbol
The mode SDK will run
124 125 126 |
# File 'lib/splitclient-rb/split_config.rb', line 124 def mode @mode end |
#read_timeout ⇒ Int
The read timeout for network connections in seconds.
129 130 131 |
# File 'lib/splitclient-rb/split_config.rb', line 129 def read_timeout @read_timeout end |
#redis_namespace ⇒ Object
Returns the value of attribute redis_namespace.
234 235 236 |
# File 'lib/splitclient-rb/split_config.rb', line 234 def redis_namespace @redis_namespace end |
#redis_url ⇒ Object
Returns the value of attribute redis_url.
233 234 235 |
# File 'lib/splitclient-rb/split_config.rb', line 233 def redis_url @redis_url end |
#segments_refresh_rate ⇒ Object
Returns the value of attribute segments_refresh_rate.
219 220 221 |
# File 'lib/splitclient-rb/split_config.rb', line 219 def segments_refresh_rate @segments_refresh_rate end |
#split_file ⇒ Object
Returns the value of attribute split_file.
252 253 254 |
# File 'lib/splitclient-rb/split_config.rb', line 252 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
173 174 175 |
# File 'lib/splitclient-rb/split_config.rb', line 173 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
181 182 183 |
# File 'lib/splitclient-rb/split_config.rb', line 181 def split_validator @split_validator end |
#threads ⇒ Object
Returns the value of attribute threads.
236 237 238 |
# File 'lib/splitclient-rb/split_config.rb', line 236 def threads @threads end |
#transport_debug_enabled ⇒ Boolean
Enable to log the content retrieved from endpoints
193 194 195 |
# File 'lib/splitclient-rb/split_config.rb', line 193 def transport_debug_enabled @transport_debug_enabled end |
#valid_mode ⇒ Object
Returns the value of attribute valid_mode.
238 239 240 |
# File 'lib/splitclient-rb/split_config.rb', line 238 def valid_mode @valid_mode end |
#version ⇒ Object
Returns the value of attribute version.
216 217 218 |
# File 'lib/splitclient-rb/split_config.rb', line 216 def version @version end |
Class Method Details
.cache_ttl ⇒ int
The default cache time to live
439 440 441 |
# File 'lib/splitclient-rb/split_config.rb', line 439 def self.cache_ttl 5 end |
.default ⇒ Config
The default split client configuration
262 263 264 |
# File 'lib/splitclient-rb/split_config.rb', line 262 def self.default SplitConfig.new end |
.default_base_uri ⇒ string
The default base uri for api calls
270 271 272 |
# File 'lib/splitclient-rb/split_config.rb', line 270 def self.default_base_uri 'https://sdk.split.io/api/' end |
.default_block_until_ready ⇒ int
The default block until ready value
415 416 417 |
# File 'lib/splitclient-rb/split_config.rb', line 415 def self.default_block_until_ready 15 end |
.default_cache_adapter ⇒ LocalStore
Returns configuration value for local cache store.
307 308 309 |
# File 'lib/splitclient-rb/split_config.rb', line 307 def self.default_cache_adapter :memory end |
.default_connection_timeout ⇒ int
The default connection timeout value
327 328 329 |
# File 'lib/splitclient-rb/split_config.rb', line 327 def self.default_connection_timeout 5 end |
.default_debug ⇒ boolean
The default debug value
391 392 393 |
# File 'lib/splitclient-rb/split_config.rb', line 391 def self.default_debug false end |
.default_events_push_rate ⇒ Object
355 356 357 |
# File 'lib/splitclient-rb/split_config.rb', line 355 def self.default_events_push_rate 60 end |
.default_events_queue_size ⇒ Object
359 360 361 |
# File 'lib/splitclient-rb/split_config.rb', line 359 def self.default_events_queue_size 500 end |
.default_events_uri ⇒ Object
274 275 276 |
# File 'lib/splitclient-rb/split_config.rb', line 274 def self.default_events_uri 'https://events.split.io/api/' end |
.default_features_refresh_rate ⇒ Object
331 332 333 |
# File 'lib/splitclient-rb/split_config.rb', line 331 def self.default_features_refresh_rate 5 end |
.default_impression_listener_refresh_rate ⇒ Object
347 348 349 |
# File 'lib/splitclient-rb/split_config.rb', line 347 def self.default_impression_listener_refresh_rate 0 end |
.default_impressions_queue_size ⇒ Object
351 352 353 |
# File 'lib/splitclient-rb/split_config.rb', line 351 def self.default_impressions_queue_size 5000 end |
.default_impressions_refresh_rate ⇒ Object
343 344 345 |
# File 'lib/splitclient-rb/split_config.rb', line 343 def self.default_impressions_refresh_rate 60 end |
.default_ip_addresses_enabled ⇒ boolean
The default ip addresses enabled value
423 424 425 |
# File 'lib/splitclient-rb/split_config.rb', line 423 def self.default_ip_addresses_enabled true end |
.default_labels_logging ⇒ boolean
The default labels logging value
399 400 401 |
# File 'lib/splitclient-rb/split_config.rb', line 399 def self.default_labels_logging true end |
.default_logger ⇒ object
The default logger object
375 376 377 378 379 380 381 382 383 |
# File 'lib/splitclient-rb/split_config.rb', line 375 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_metrics_adapter ⇒ Object
311 312 313 |
# File 'lib/splitclient-rb/split_config.rb', line 311 def self.default_metrics_adapter :memory end |
.default_metrics_refresh_rate ⇒ Object
339 340 341 |
# File 'lib/splitclient-rb/split_config.rb', line 339 def self.default_metrics_refresh_rate 60 end |
.default_mode ⇒ Object
302 303 304 |
# File 'lib/splitclient-rb/split_config.rb', line 302 def self.default_mode :standalone end |
.default_offline_refresh_rate ⇒ Object
367 368 369 |
# File 'lib/splitclient-rb/split_config.rb', line 367 def self.default_offline_refresh_rate 5 end |
.default_read_timeout ⇒ int
The default read timeout value
319 320 321 |
# File 'lib/splitclient-rb/split_config.rb', line 319 def self.default_read_timeout 5 end |
.default_redis_namespace ⇒ Object
407 408 409 |
# File 'lib/splitclient-rb/split_config.rb', line 407 def self.default_redis_namespace 'SPLITIO' end |
.default_redis_url ⇒ Object
403 404 405 |
# File 'lib/splitclient-rb/split_config.rb', line 403 def self.default_redis_url 'redis://127.0.0.1:6379/0' end |
.default_segments_refresh_rate ⇒ Object
335 336 337 |
# File 'lib/splitclient-rb/split_config.rb', line 335 def self.default_segments_refresh_rate 60 end |
.default_split_file ⇒ Object
363 364 365 |
# File 'lib/splitclient-rb/split_config.rb', line 363 def self.default_split_file File.join(Dir.home, '.split') end |
.init_cache_adapter(adapter, data_structure, queue_size = nil, redis_url = nil) ⇒ Object
278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
# File 'lib/splitclient-rb/split_config.rb', line 278 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 |
.machine_hostname(ip_addresses_enabled, machine_name, adapter) ⇒ string
gets the hostname where the sdk gem is running
493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 |
# File 'lib/splitclient-rb/split_config.rb', line 493 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
514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 |
# File 'lib/splitclient-rb/split_config.rb', line 514 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
293 294 295 296 297 298 299 300 |
# File 'lib/splitclient-rb/split_config.rb', line 293 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
446 447 448 |
# File 'lib/splitclient-rb/split_config.rb', line 446 def self.max_cache_size 500 end |
.max_key_size ⇒ int
The default max key size
453 454 455 |
# File 'lib/splitclient-rb/split_config.rb', line 453 def self.max_key_size 250 end |
.transport_debug ⇒ boolean
The default transport_debug_enabled value
431 432 433 |
# File 'lib/splitclient-rb/split_config.rb', line 431 def self.transport_debug false end |
Instance Method Details
#consumer? ⇒ Boolean
485 486 487 |
# File 'lib/splitclient-rb/split_config.rb', line 485 def consumer? @mode.equal?(:consumer) end |
#log_found_exception(caller, error) ⇒ void
This method returns an undefined value.
custom logger of exceptions
461 462 463 464 465 466 467 468 |
# File 'lib/splitclient-rb/split_config.rb', line 461 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
481 482 483 |
# File 'lib/splitclient-rb/split_config.rb', line 481 def standalone? @mode.equal?(:standalone) end |
#startup_log ⇒ void
This method returns an undefined value.
log which cache class was loaded and SDK mode
474 475 476 477 478 479 |
# File 'lib/splitclient-rb/split_config.rb', line 474 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 |