Class DynamoDBStoreBuilder<T>
A builder for configuring the DynamoDB-based persistent data store.
Inheritance
Implements
Namespace: LaunchDarkly.Sdk.Server.Integrations
Assembly: LaunchDarkly.ServerSdk.DynamoDB.dll
Syntax
public abstract class DynamoDBStoreBuilder<T> : Object, IComponentConfigurer<T>, IDiagnosticDescription
Type Parameters
| Name | Description |
|---|---|
| T |
Remarks
This can be used either for the main data store that holds feature flag data, or for the big segment store, or both. If you are using both, they do not have to have the same parameters. For instance, in this example the main data store uses a table called "table1" and the big segment store uses a table called "table2":
var config = Configuration.Builder("sdk-key")
.DataStore(
Components.PersistentDataStore(
DynamoDB.DataStore("table1")
)
)
.BigSegments(
Components.BigSegments(
DynamoDB.DataStore("table2")
)
)
.Build();
Note that the builder is passed to one of two methods, LaunchDarkly.Sdk.Server.Components.PersistentDataStore(LaunchDarkly.Sdk.Server.Subsystems.IComponentConfigurer{LaunchDarkly.Sdk.Server.Subsystems.IPersistentDataStoreAsync}) or LaunchDarkly.Sdk.Server.Components.BigSegments(LaunchDarkly.Sdk.Server.Subsystems.IComponentConfigurer{LaunchDarkly.Sdk.Server.Subsystems.IBigSegmentStore}), depending on the context in which it is being used. This is because each of those contexts has its own additional configuration options that are unrelated to the DynamoDB options. For instance, the LaunchDarkly.Sdk.Server.Components.PersistentDataStore(LaunchDarkly.Sdk.Server.Subsystems.IComponentConfigurer{LaunchDarkly.Sdk.Server.Subsystems.IPersistentDataStore}) builder has options for caching:
var config = Configuration.Builder("sdk-key")
.DataStore(
Components.PersistentDataStore(
DynamoDB.DataStore("table1")
).CacheSeconds(15)
)
.Build();
Builder calls can be chained, for example:
var config = Configuration.Builder("sdk-key")
.DataStore(
Components.PersistentDataStore(
DynamoDB.DataStore("my-table-name")
.Credentials(myAWSCredentials)
.Prefix("app1")
)
.CacheSeconds(15)
)
.Build();
Methods
Build(LdClientContext)
Declaration
public abstract T Build(LdClientContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| LaunchDarkly.Sdk.Server.Subsystems.LdClientContext | context |
Returns
| Type | Description |
|---|---|
| T |
Configuration(AmazonDynamoDBConfig)
Specifies an entire DynamoDB configuration.
Declaration
public DynamoDBStoreBuilder<T> Configuration(AmazonDynamoDBConfig config)
Parameters
| Type | Name | Description |
|---|---|---|
| Amazon.DynamoDBv2.AmazonDynamoDBConfig | config | a DynamoDB configuration object |
Returns
| Type | Description |
|---|---|
| DynamoDBStoreBuilder<T> | the builder |
Remarks
If this is not provided explicitly, the AWS SDK will attempt to determine your current region based on environment variables and/or local configuration files.
Credentials(AWSCredentials)
Sets the AWS client credentials.
Declaration
public DynamoDBStoreBuilder<T> Credentials(AWSCredentials credentials)
Parameters
| Type | Name | Description |
|---|---|---|
| Amazon.Runtime.AWSCredentials | credentials | the AWS credentials |
Returns
| Type | Description |
|---|---|
| DynamoDBStoreBuilder<T> | the builder |
Remarks
If you do not set them programmatically, the AWS SDK will attempt to find them in environment variables and/or local configuration files.
DescribeConfiguration(LdClientContext)
Declaration
public LdValue DescribeConfiguration(LdClientContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| LaunchDarkly.Sdk.Server.Subsystems.LdClientContext | context |
Returns
| Type | Description |
|---|---|
| LaunchDarkly.Sdk.LdValue |
ExistingClient(AmazonDynamoDBClient)
Specifies an existing, already-configured DynamoDB client instance that the data store should use rather than creating one of its own.
Declaration
public DynamoDBStoreBuilder<T> ExistingClient(AmazonDynamoDBClient client)
Parameters
| Type | Name | Description |
|---|---|---|
| Amazon.DynamoDBv2.AmazonDynamoDBClient | client | an existing DynamoDB client instance |
Returns
| Type | Description |
|---|---|
| DynamoDBStoreBuilder<T> | the builder |
Remarks
If you specify an existing client, then the other builder methods for configuring DynamoDB are ignored.
Note that the LaunchDarkly code will not take ownership of the lifecycle of this
object: in other words, it will not call Dispose() on the AmazonDynamoDBClient when
you dispose of the SDK client, as it would if it had created the AmazonDynamoDBClient itself.
It is your responsibility to call Dispose() on the AmazonDynamoDBClient when you are
done with it.
Prefix(String)
Sets an optional namespace prefix for all keys stored in DynamoDB.
Declaration
public DynamoDBStoreBuilder<T> Prefix(string prefix)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | prefix | the namespace prefix; null for no prefix |
Returns
| Type | Description |
|---|---|
| DynamoDBStoreBuilder<T> | the builder |
Remarks
You may use this if you are sharing the same database table between multiple clients that are for different LaunchDarkly environments, to avoid key collisions. However, in DynamoDB it is common to use separate tables rather than share a single table for unrelated applications, so by default there is no prefix.