Documentation ¶
Overview ¶
Package lddynamodb provides a DynamoDB-backed persistent data store for the LaunchDarkly Go SDK.
For more details about how and why you can use a persistent data store, see: https://docs.launchdarkly.com/sdk/features/storing-data/dynamodb#go
To use the DynamoDB data store with the LaunchDarkly client:
import lddynamodb "github.com/launchdarkly/go-server-sdk-dynamodb" config := ld.Config{ DataStore: ldcomponents.PersistentDataStore(lddynamodb.DataStore("my-table-name")), } client, err := ld.MakeCustomClient("sdk-key", config, 5*time.Second)
By default, the data store uses a basic DynamoDB client configuration that is equivalent to doing this:
dynamoClient := dynamodb.New(session.NewSession())
This default configuration will only work if your AWS credentials and region are available from AWS environment variables and/or configuration files. If you want to set those programmatically or modify any other configuration settings, you can use the methods of the lddynamodb.DataStoreBuilder returned by lddynamodb.DataStore(). For example:
config := ld.Config{ DataStore: ldcomponents.PersistentDataStore( lddynamodb.DataStore("my-table-name").Prefix("key-prefix"), ).CacheSeconds(30), }
Note that CacheSeconds() is not a method of lddynamodb.DataStoreBuilder, but rather a method of ldcomponents.PersistentDataStore(), because the caching behavior is provided by the SDK for all database integrations.
If you are also using DynamoDB for other purposes, the data store can coexist with other data in the same table as long as you use the Prefix option to make each application use different keys. However, it is advisable to configure separate tables in DynamoDB, for better control over permissions and throughput.
Index ¶
- type DataStoreBuilder
- func (b *DataStoreBuilder) ClientConfig(config *aws.Config) *DataStoreBuilder
- func (b *DataStoreBuilder) CreateBigSegmentStore(context interfaces.ClientContext) (interfaces.BigSegmentStore, error)
- func (b *DataStoreBuilder) CreatePersistentDataStore(context interfaces.ClientContext) (interfaces.PersistentDataStore, error)
- func (b *DataStoreBuilder) DescribeConfiguration() ldvalue.Value
- func (b *DataStoreBuilder) DynamoClient(client dynamodbiface.DynamoDBAPI) *DataStoreBuilder
- func (b *DataStoreBuilder) Prefix(prefix string) *DataStoreBuilder
- func (b *DataStoreBuilder) SessionOptions(options session.Options) *DataStoreBuilder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DataStoreBuilder ¶
type DataStoreBuilder struct {
// contains filtered or unexported fields
}
DataStoreBuilder is a builder for configuring the DynamoDB-based persistent data store.
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 the table "table1" and the big segment store uses the table "table2":
config.DataStore = ldcomponents.PersistentDataStore( lddynamodb.DataStore("table1")) config.BigSegments = ldcomponents.BigSegments( lddynamodb.DataStore("table2"))
Note that the builder is passed to one of two methods, PersistentDataStore or BigSegments, 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.
Builder calls can be chained, for example:
config.DataStore = lddynamodb.DataStore("tablename").SessionOptions(someOption).Prefix("prefix")
You do not need to call the builder's CreatePersistentDataStore() method yourself to build the actual data store; that will be done by the SDK.
func DataStore ¶
func DataStore(tableName string) *DataStoreBuilder
DataStore returns a configurable builder for a DynamoDB-backed data store.
The tableName parameter is required, and the table must already exist in DynamoDB.
func (*DataStoreBuilder) ClientConfig ¶
func (b *DataStoreBuilder) ClientConfig(config *aws.Config) *DataStoreBuilder
ClientConfig adds an AWS configuration object for the DynamoDB client. This allows you to customize settings such as the retry behavior.
func (*DataStoreBuilder) CreateBigSegmentStore ¶ added in v1.1.0
func (b *DataStoreBuilder) CreateBigSegmentStore( context interfaces.ClientContext, ) (interfaces.BigSegmentStore, error)
CreateBigSegmentStore is called internally by the SDK to create a data store implementation object.
func (*DataStoreBuilder) CreatePersistentDataStore ¶
func (b *DataStoreBuilder) CreatePersistentDataStore( context interfaces.ClientContext, ) (interfaces.PersistentDataStore, error)
CreatePersistentDataStore is called internally by the SDK to create a data store implementation object.
func (*DataStoreBuilder) DescribeConfiguration ¶
func (b *DataStoreBuilder) DescribeConfiguration() ldvalue.Value
DescribeConfiguration is used internally by the SDK to inspect the configuration.
func (*DataStoreBuilder) DynamoClient ¶
func (b *DataStoreBuilder) DynamoClient(client dynamodbiface.DynamoDBAPI) *DataStoreBuilder
DynamoClient specifies an existing DynamoDB client instance. Use this if you want to customize the client used by the data store in ways that are not supported by other DataStoreBuilder options. If you specify this option, then any configurations specified with SessionOptions or ClientConfig will be ignored.
func (*DataStoreBuilder) Prefix ¶
func (b *DataStoreBuilder) Prefix(prefix string) *DataStoreBuilder
Prefix specifies a prefix for namespacing the data store's keys.
func (*DataStoreBuilder) SessionOptions ¶
func (b *DataStoreBuilder) SessionOptions(options session.Options) *DataStoreBuilder
SessionOptions specifies an AWS Session.Options object to use when creating the DynamoDB session. This can be used to set properties such as the region programmatically, rather than relying on the defaults from the environment.