Class: LaunchDarkly::BigSegmentsConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/ldclient-rb/config.rb

Overview

Configuration options related to Big Segments.

Big Segments are a specific type of segments. For more information, read the LaunchDarkly documentation: docs.launchdarkly.com/home/users/big-segments

If your application uses Big Segments, you will need to create a ‘BigSegmentsConfig` that at a minimum specifies what database integration to use, and then pass the `BigSegmentsConfig` object as the `big_segments` parameter when creating a Config.

Examples:

Configuring Big Segments with Redis

store = LaunchDarkly::Integrations::Redis::new_big_segments_store(redis_url: "redis://my-server")
config = LaunchDarkly::Config.new(big_segments:
  LaunchDarkly::BigSegmentsConfig.new(store: store))
client = LaunchDarkly::LDClient.new(my_sdk_key, config)

Constant Summary collapse

DEFAULT_CONTEXT_CACHE_SIZE =
1000
DEFAULT_CONTEXT_CACHE_TIME =
5
DEFAULT_STATUS_POLL_INTERVAL =
5
DEFAULT_STALE_AFTER =
2 * 60

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(store:, context_cache_size: nil, context_cache_time: nil, status_poll_interval: nil, stale_after: nil) ⇒ BigSegmentsConfig

Constructor for setting Big Segments options.

Parameters:



601
602
603
604
605
606
607
# File 'lib/ldclient-rb/config.rb', line 601

def initialize(store:, context_cache_size: nil, context_cache_time: nil, status_poll_interval: nil, stale_after: nil)
  @store = store
  @context_cache_size = context_cache_size.nil? ? DEFAULT_CONTEXT_CACHE_SIZE : context_cache_size
  @context_cache_time = context_cache_time.nil? ? DEFAULT_CONTEXT_CACHE_TIME : context_cache_time
  @status_poll_interval = status_poll_interval.nil? ? DEFAULT_STATUS_POLL_INTERVAL : status_poll_interval
  @stale_after = stale_after.nil? ? DEFAULT_STALE_AFTER : stale_after
end

Instance Attribute Details

#context_cache_sizeInteger (readonly) Also known as: user_cache_size

The maximum number of contexts whose Big Segment state will be cached by the SDK at any given time.

Returns:

  • (Integer)


616
617
618
# File 'lib/ldclient-rb/config.rb', line 616

def context_cache_size
  @context_cache_size
end

#context_cache_timeFloat (readonly) Also known as: user_cache_time

The maximum length of time (in seconds) that the Big Segment state for a context will be cached by the SDK.

Returns:

  • (Float)


628
629
630
# File 'lib/ldclient-rb/config.rb', line 628

def context_cache_time
  @context_cache_time
end

#stale_afterFloat (readonly)

The maximum length of time between updates of the Big Segments data before the data is considered out of date.

Returns:

  • (Float)


645
646
647
# File 'lib/ldclient-rb/config.rb', line 645

def stale_after
  @stale_after
end

#status_poll_intervalFloat (readonly)

The interval (in seconds) at which the SDK will poll the Big Segment store to make sure it is available and to determine how long ago it was updated.

Returns:

  • (Float)


640
641
642
# File 'lib/ldclient-rb/config.rb', line 640

def status_poll_interval
  @status_poll_interval
end

#storeLaunchDarkly::Interfaces::BigSegmentStore (readonly)

The implementation of Interfaces::BigSegmentStore that will be used to query the Big Segments database.



612
613
614
# File 'lib/ldclient-rb/config.rb', line 612

def store
  @store
end