Module: LaunchDarkly::Integrations::DynamoDB

Defined in:
lib/ldclient-rb/integrations.rb,
lib/ldclient-rb/integrations/dynamodb.rb

Overview

Integration with DynamoDB.

Note that in order to use this integration, you must first install one of the AWS SDK gems: either aws-sdk-dynamodb, or the full aws-sdk.

Since:

  • 5.5.0

Class Method Summary collapse

Class Method Details

.new_feature_store(table_name, opts) ⇒ LaunchDarkly::Interfaces::FeatureStore

Creates a DynamoDB-backed persistent feature store. For more details about how and why you can use a persistent feature store, see the SDK reference guide.

To use this method, you must first install one of the AWS SDK gems: either aws-sdk-dynamodb, or the full aws-sdk. Then, put the object returned by this method into the feature_store property of your client configuration (Config).

Note that the specified table must already exist in DynamoDB. It must have a partition key called "namespace", and a sort key called "key" (both strings). The SDK does not create the table automatically because it has no way of knowing what additional properties (such as permissions and throughput) you would want it to have.

By default, the DynamoDB client will try to get your AWS credentials and region name from environment variables and/or local configuration files, as described in the AWS SDK documentation. You can also specify any supported AWS SDK options in dynamodb_opts-- or, provide an already-configured DynamoDB client in existing_client.

Examples:

Configuring the feature store

store = LaunchDarkly::Integrations::DynamoDB::new_feature_store("my-table-name")
config = LaunchDarkly::Config.new(feature_store: store)
client = LaunchDarkly::LDClient.new(my_sdk_key, config)

Parameters:

  • table_name (String)

    name of an existing DynamoDB table

  • opts (Hash)

    the configuration options

Options Hash (opts):

  • :dynamodb_opts (Hash)

    options to pass to the DynamoDB client constructor (ignored if you specify :existing_client)

  • :existing_client (Object)

    an already-constructed DynamoDB client for the feature store to use

  • :prefix (String)

    namespace prefix to add to all keys used by LaunchDarkly

  • :logger (Logger)

    a Logger instance; defaults to Config.default_logger

  • :expiration (Integer) — default: 15

    expiration time for the in-memory cache, in seconds; 0 for no local caching

  • :capacity (Integer) — default: 1000

    maximum number of items in the cache

Returns:

Since:

  • 5.5.0



41
42
43
44
# File 'lib/ldclient-rb/integrations/dynamodb.rb', line 41

def self.new_feature_store(table_name, opts)
  core = LaunchDarkly::Impl::Integrations::DynamoDB::DynamoDBFeatureStoreCore.new(table_name, opts)
  return LaunchDarkly::Integrations::Util::CachingStoreWrapper.new(core, opts)
end