diff --git a/package_info.go b/package_info.go index b86cab0..d226620 100644 --- a/package_info.go +++ b/package_info.go @@ -1,25 +1,25 @@ // Package ldredis provides a Redis-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/v2.0/docs/using-a-persistent-feature-store +// https://docs.launchdarkly.com/sdk/concepts/data-stores // // To use the Redis data store with the LaunchDarkly client: // -// import ldredis "github.com/launchdarkly/go-server-sdk-redis-go-redis" +// import ldredis "github.com/launchdarkly/go-server-sdk-redis-go-redis" // -// config := ld.Config{ -// DataStore: ldcomponents.PersistentDataStore(ldredis.DataStore()), -// } -// client, err := ld.MakeCustomClient("sdk-key", config, 5*time.Second) +// config := ld.Config{ +// DataStore: ldcomponents.PersistentDataStore(ldredis.DataStore()), +// } +// client, err := ld.MakeCustomClient("sdk-key", config, 5*time.Second) // // The default configuration uses an address of localhost:6379. You may customize the configuration // by using the methods of the ldredis.DataStoreBuilder returned by ldredis.DataStore(): // -// config := ld.Config{ -// DataStore: ldcomponents.PersistentDataStore( -// ldredis.DataStore().URL(myRedisURL), -// ).CacheSeconds(30), -// } +// config := ld.Config{ +// DataStore: ldcomponents.PersistentDataStore( +// ldredis.DataStore().URL(myRedisURL), +// ).CacheSeconds(30), +// } // // Note that CacheSeconds() is not a method of ldredis.DataStoreBuilder, but rather a method of // ldcomponents.PersistentDataStore(), because the caching behavior is provided by the SDK for @@ -32,5 +32,5 @@ // If you are also using Redis for other purposes, the data store can coexist with // other data as long as you are not using the same keys. By default, the keys used by the // data store will always start with "launchdarkly:"; you can change this to another -// prefix if desired. +// prefix if desired using the ldredis.DataStoreBuilder's Prefix method. package ldredis diff --git a/redis_builder.go b/redis_builder.go index bfb8315..92fe731 100644 --- a/redis_builder.go +++ b/redis_builder.go @@ -55,7 +55,7 @@ func DataStore() *DataStoreBuilder { // // config.DataStore = ldredis.DataStore().URL("redis://hostname").Prefix("prefix") // -// You do not need to call the builder's CreatePersistentDataStore() method yourself to build the +// You do not need to call the builder's Build() method yourself to build the // actual data store; that will be done by the SDK. type DataStoreBuilder struct { prefix string @@ -114,7 +114,7 @@ func (b *DataStoreBuilder) Prefix(prefix string) *DataStoreBuilder { return b } -// Options sets all of the parameters supported by the go-redis UniversalOptions type. +// Options sets all the parameters supported by the go-redis UniversalOptions type. // // This overwrites any previous setting of HostAndPort or Addresses. func (b *DataStoreBuilder) Options(options redis.UniversalOptions) *DataStoreBuilder { @@ -124,7 +124,7 @@ func (b *DataStoreBuilder) Options(options redis.UniversalOptions) *DataStoreBui // URL specifies the Redis host URL. If not specified, the default value is DefaultURL. // -// Note that some Redis client features can specified either as part of the URL or with Options. For instance, +// Note that some Redis client features can be specified either as part of the URL or with Options. For instance, // the Password and DB fields in Options can be part of a "redis://" URL // (https://www.iana.org/assignments/uri-schemes/prov/redis), and TLS can be enabled either by setting the // TLSConfig in Options or by using a "rediss://" URL (https://www.iana.org/assignments/uri-schemes/prov/rediss). @@ -153,7 +153,7 @@ func (b *DataStoreBuilder) Build( if b.url != "" { if len(redisOpts.Addrs) > 0 { - return nil, errors.New("Redis data store must be configured with either Options.Address or URL, but not both") + return nil, errors.New("redis data store must be configured with either Options.Address or URL, but not both") } parsed, err := redis.ParseURL(b.url) if err != nil { diff --git a/redis_builder_test.go b/redis_builder_test.go index b8e6379..481346d 100644 --- a/redis_builder_test.go +++ b/redis_builder_test.go @@ -32,7 +32,9 @@ func TestDataSourceBuilder(t *testing.T) { assert.Equal(t, DefaultPrefix, makeStore(DataStore().Prefix("")).prefix) - // assert.Equal(t, DefaultClusterPrefix + "p", makeStore(DataStore().Prefix("p").)) + assert.Equal(t, DefaultClusterPrefix+"p", makeStore( + DataStore().Addresses("a", "b").Prefix("p")).prefix, + ) }) t.Run("URL", func(t *testing.T) {