Module: LaunchDarkly

Defined in:
lib/ldclient-rb.rb,
lib/ldclient-rb/impl.rb,
lib/ldclient-rb/util.rb,
lib/ldclient-rb/config.rb,
lib/ldclient-rb/events.rb,
lib/ldclient-rb/stream.rb,
lib/ldclient-rb/context.rb,
lib/ldclient-rb/polling.rb,
lib/ldclient-rb/version.rb,
lib/ldclient-rb/ldclient.rb,
lib/ldclient-rb/impl/util.rb,
lib/ldclient-rb/reference.rb,
lib/ldclient-rb/requestor.rb,
lib/ldclient-rb/interfaces.rb,
lib/ldclient-rb/migrations.rb,
lib/ldclient-rb/cache_store.rb,
lib/ldclient-rb/flags_state.rb,
lib/ldclient-rb/impl/context.rb,
lib/ldclient-rb/impl/sampler.rb,
lib/ldclient-rb/expiring_cache.rb,
lib/ldclient-rb/impl/evaluator.rb,
lib/ldclient-rb/memoized_value.rb,
lib/ldclient-rb/impl/data_store.rb,
lib/ldclient-rb/in_memory_store.rb,
lib/ldclient-rb/impl/broadcaster.rb,
lib/ldclient-rb/impl/data_source.rb,
lib/ldclient-rb/impl/event_types.rb,
lib/ldclient-rb/simple_lru_cache.rb,
lib/ldclient-rb/evaluation_detail.rb,
lib/ldclient-rb/impl/big_segments.rb,
lib/ldclient-rb/impl/event_sender.rb,
lib/ldclient-rb/impl/flag_tracker.rb,
lib/ldclient-rb/impl/model/clause.rb,
lib/ldclient-rb/impl/model/segment.rb,
lib/ldclient-rb/integrations/redis.rb,
lib/ldclient-rb/impl/context_filter.rb,
lib/ldclient-rb/impl/repeating_task.rb,
lib/ldclient-rb/impl/unbounded_pool.rb,
lib/ldclient-rb/integrations/consul.rb,
lib/ldclient-rb/impl/event_summarizer.rb,
lib/ldclient-rb/integrations/dynamodb.rb,
lib/ldclient-rb/impl/diagnostic_events.rb,
lib/ldclient-rb/impl/evaluator_helpers.rb,
lib/ldclient-rb/integrations/file_data.rb,
lib/ldclient-rb/integrations/test_data.rb,
lib/ldclient-rb/impl/dependency_tracker.rb,
lib/ldclient-rb/impl/migrations/tracker.rb,
lib/ldclient-rb/impl/model/feature_flag.rb,
lib/ldclient-rb/impl/evaluator_bucketing.rb,
lib/ldclient-rb/impl/evaluator_operators.rb,
lib/ldclient-rb/impl/migrations/migrator.rb,
lib/ldclient-rb/impl/model/serialization.rb,
lib/ldclient-rb/non_blocking_thread_pool.rb,
lib/ldclient-rb/impl/store_client_wrapper.rb,
lib/ldclient-rb/impl/store_data_set_sorter.rb,
lib/ldclient-rb/impl/integrations/redis_impl.rb,
lib/ldclient-rb/impl/model/preprocessed_data.rb,
lib/ldclient-rb/impl/integrations/consul_impl.rb,
lib/ldclient-rb/impl/integrations/dynamodb_impl.rb,
lib/ldclient-rb/integrations/util/store_wrapper.rb,
lib/ldclient-rb/impl/integrations/file_data_source.rb,
lib/ldclient-rb/integrations/test_data/flag_builder.rb,
lib/ldclient-rb/impl/integrations/test_data/test_data_source.rb

Overview

General implementation notes about the data model classes in LaunchDarkly::Impl::Model–

As soon as we receive flag/segment JSON data from LaunchDarkly (or, read it from a database), we transform it into the model classes FeatureFlag, Segment, etc. The constructor of each of these classes takes a hash (the parsed JSON), and transforms it into an internal representation that is more efficient for evaluations.

Validation works as follows:

  • A property value that is of the correct type, but is invalid for other reasons (for example,

if a flag rule refers to variation index 5, but there are only 2 variations in the flag), does not prevent the flag from being parsed and stored. It does cause a warning to be logged, if a logger was passed to the constructor.

  • If a value is completely invalid for the schema, the constructor may throw an

exception, causing the whole data set to be rejected. This is consistent with the behavior of the strongly-typed SDKs.

Currently, the model classes also retain the original hash of the parsed JSON. This is because we may need to re-serialize them to JSON, and building the JSON on the fly would be very inefficient, so each model class has a to_json method that just returns the same Hash. If we are able in the future to either use a custom streaming serializer, or pass the JSON data straight through from LaunchDarkly to a database instead of re-serializing, we could stop retaining this data.

Defined Under Namespace

Modules: BigSegmentsStatus, EventProcessorMethods, Impl, Integrations, Interfaces, Migrations, Util Classes: BigSegmentsConfig, Config, DiagnosticEventMessage, EvaluationDetail, EvaluationReason, EventBuffer, EventDispatcher, EventOutputFormatter, EventProcessor, ExpiringCache, FeatureFlagsState, FlushContextsMessage, FlushMessage, FlushPayload, InMemoryFeatureStore, LDClient, LDContext, MemoizedValue, NonBlockingThreadPool, NullEventProcessor, NullUpdateProcessor, PollingProcessor, Reference, Requestor, Result, SimpleLRUCacheSet, StopMessage, StreamProcessor, SynchronousMessage, TestSyncMessage, ThreadSafeMemoryStore, UnexpectedResponseError

Constant Summary collapse

PUT =
:put
PATCH =
:patch
DELETE =
:delete
READ_TIMEOUT_SECONDS =
300
KEY_PATHS =
{
  FEATURES => "/flags/",
  SEGMENTS => "/segments/",
}
VERSION =
"8.0.0"
FEATURES =
{
  namespace: "features",
  priority: 1,  # that is, features should be stored after segments
  get_dependency_keys: lambda { |flag| (flag[:prerequisites] || []).map { |p| p[:key] } },
}.freeze
SEGMENTS =
{
  namespace: "segments",
  priority: 0,
}.freeze
ALL_KINDS =
[FEATURES, SEGMENTS].freeze