Skip to content
This repository has been archived by the owner on Oct 11, 2019. It is now read-only.

Commit

Permalink
prepare 4.5.0 release (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
eli-darkly authored Nov 15, 2018
1 parent c4a8657 commit f1dd8d5
Show file tree
Hide file tree
Showing 5,119 changed files with 2,357,518 additions and 555 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
9 changes: 8 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ defaults:
if [ -z "$DISABLE_COVERAGE" ]; then
go_cover_args="-covermode=atomic -coverprofile /tmp/circle-artifacts/coverage.txt"
fi
go test -race $go_cover_args -v . ./redis | tee >(richgo testfilter) > $CIRCLE_ARTIFACTS/report.txt
# Note, we need to specify all these packages individually for go test in order to remain 1.8-compatible
go test -race $go_cover_args -v . ./redis ./ldconsul ./lddynamodb ./ldfiledata ./ldfilewatch ./utils | tee >(richgo testfilter) > $CIRCLE_ARTIFACTS/report.txt
if [ -z "$DISABLE_COVERAGE" ]; then
./cc-test-reporter format-coverage $CIRCLE_ARTIFACTS/coverage.txt -t gocov --output $CIRCLE_ARTIFACTS/coverage.json
./cc-test-reporter upload-coverage --input $CIRCLE_ARTIFACTS/coverage.json
Expand Down Expand Up @@ -70,6 +71,8 @@ jobs:
environment:
<<: *environment
- image: redis
- image: consul
- image: amazon/dynamodb-local

<<: *build_steps

Expand All @@ -82,6 +85,8 @@ jobs:
<<: *environment
DISABLE_COVERAGE: 1
- image: redis
- image: consul
- image: amazon/dynamodb-local

<<: *build_steps

Expand All @@ -94,6 +99,8 @@ jobs:
<<: *environment
DISABLE_COVERAGE: 1
- image: redis
- image: consul
- image: amazon/dynamodb-local

<<: *build_steps

Expand Down
2 changes: 1 addition & 1 deletion CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @ashanbrown

87 changes: 84 additions & 3 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ if showFeature {
}
```

Database integrations
---------------------

Feature flag data can be kept in a persistent store using Redis, Consul, or DynamoDB. These adapters are implemented in the subpackages `redis`, `ldconsul`, and `lddynamodb`; to use them, call the `New...FeatureStore` function provided by the subpackage, and put the returned object in the `FeatureStore` field of your client configuration. See the subpackages and the [SDK reference guide](https://docs.launchdarkly.com/v2.0/docs/using-a-persistent-feature-store) for more information.

Learn more
-----------

Expand Down
38 changes: 32 additions & 6 deletions feature_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,44 @@ import (
"sync"
)

// FeatureStore is an interface describing a structure that maintains the live collection of features and related objects.
// It is used by LaunchDarkly when streaming mode is enabled, and stores data returned
// by the streaming API. Custom FeatureStore implementations can be passed to the
// LaunchDarkly client via a custom Config object. LaunchDarkly provides two FeatureStore
// implementations: one backed by an in-memory map, and one backed by Redis.
// Implementations must be thread-safe.
// FeatureStore is an interface describing a structure that maintains the live collection of features
// and related objects. Whenever the SDK retrieves feature flag data from LaunchDarkly, via streaming
// or polling, it puts the data into the FeatureStore; then it queries the store whenever a flag needs
// to be evaluated. Therefore, implementations must be thread-safe.
//
// The SDK provides a default in-memory implementation (NewInMemoryFeatureStore), as well as database
// integrations in the "redis", "ldconsul", and "lddynamodb" packages. To use an implementation other
// than the default, put an instance of it in the FeatureStore property of your client configuration.
//
// If you want to create a custom implementation, it may be helpful to use the FeatureStoreWrapper
// type in the utils package; this provides commonly desired behaviors such as caching. Custom
// implementations must be able to handle any objects that implement the VersionedData interface,
// so if they need to marshal objects, the marshaling must be reflection-based. The VersionedDataKind
// type provides the necessary metadata to support this.
type FeatureStore interface {
// Get attempts to retrieve an item of the specified kind from the data store using its unique key.
// If no such item exists, it returns nil. If the item exists but has a Deleted property that is true,
// it returns nil.
Get(kind VersionedDataKind, key string) (VersionedData, error)
// All retrieves all items of the specified kind from the data store, returning a map of keys to
// items. Any items whose Deleted property is true must be omitted. If the store is empty, it
// returns an empty map.
All(kind VersionedDataKind) (map[string]VersionedData, error)
// Init performs an update of the entire data store, replacing any existing data.
Init(map[VersionedDataKind]map[string]VersionedData) error
// Delete removes the specified item from the data store, unless its Version property is greater
// than or equal to the specified version, in which case nothing happens. Removal should be done
// by storing an item whose Deleted property is true (use VersionedDataKind.MakeDeleteItem()).
Delete(kind VersionedDataKind, key string, version int) error
// Upsert adds or updates the specified item, unless the existing item in the store has a Version
// property greater than or equal to the new item's Version, in which case nothing happens.
Upsert(kind VersionedDataKind, item VersionedData) error
// Initialized returns true if the data store contains a data set, meaning that Init has been
// called at least once. In a shared data store, it should be able to detect this even if Init
// was called in a different process, i.e. the test should be based on looking at what is in
// the data store. Once this has been determined to be true, it can continue to return true
// without having to check the store again; this method should be as fast as possible since it
// may be called during feature flag evaluations.
Initialized() bool
}

Expand Down
6 changes: 3 additions & 3 deletions feature_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import (
ldtest "gopkg.in/launchdarkly/go-client.v4/shared_test"
)

func makeInMemoryStore() ld.FeatureStore {
return ld.NewInMemoryFeatureStore(nil)
func makeInMemoryStore() (ld.FeatureStore, error) {
return ld.NewInMemoryFeatureStore(nil), nil
}

func TestInMemoryFeatureStore(t *testing.T) {
ldtest.RunFeatureStoreTests(t, makeInMemoryStore)
ldtest.RunFeatureStoreTests(t, makeInMemoryStore, nil, false)
}
Loading

0 comments on commit f1dd8d5

Please sign in to comment.