Skip to content

Commit

Permalink
adding doc
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Poignant <[email protected]>
  • Loading branch information
thomaspoignant committed Jan 29, 2024
1 parent 605b1f5 commit bca8893
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ The available retrievers are:
- **Local file**
- **Google Cloud Storage**
- **Kubernetes ConfigMaps**
- **MongoDB**

_[See the full list and more information.](https://gofeatureflag.org/docs/configure_flag/store_your_flags)_

Expand Down
9 changes: 9 additions & 0 deletions website/docs/configure_flag/store_your_flags.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import gitlablogo from '@site/static/docs/retrievers/gitlab.png';
import googlelogo from '@site/static/docs/retrievers/google.png';
import s3logo from '@site/static/docs/retrievers/s3.png';
import k8slogo from '@site/static/docs/retrievers/k8s.png';
import mongodblogo from '@site/static/docs/retrievers/mongodb.png';


# Where to store your flags' configuration?
Expand Down Expand Up @@ -96,6 +97,14 @@ configuration and will evaluate your feature flags based on this configuration.
goModuleLink={'../go_module/store_file/file'}
/>
},
{
logoImg: mongodblogo,
title:"MongoDB",
content: <ConfigCardContent
relayproxyLink={'../relay_proxy/configure_relay_proxy#mongodb'}
goModuleLink={'../go_module/store_file/mongodb'}
/>
},
{
logoImg: customlogo,
title:"Custom ...",
Expand Down
2 changes: 1 addition & 1 deletion website/docs/go_module/store_file/file.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 7
sidebar_position: 25
---

# File
Expand Down
55 changes: 55 additions & 0 deletions website/docs/go_module/store_file/mongodb.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
sidebar_position: 7
---

# MongoDB
The `mongodbRetriever` will use the mongoDB database to get your flags.

## Example
```go linenums="1"
awsConfig, _ := config.LoadDefaultConfig(context.Background())
err := ffclient.Init(ffclient.Config{
PollingInterval: 3 * time.Second,
Retriever: &mongodbretriever.Retriever{
Collection: "featureFlags",
Database: "appConfig",
URI: "mongodb://root:[email protected]:27017/",
},
})
defer ffclient.Close()
```

## Expected format
If you use mongodb to store your flags, you need a specific format to store your flags.

We expect the flag to be store in JSON format as defined in the [flag format](../configure_flag/flag_format#format-details),
but you should also add a new field called ` "flag` containing the name of the flag.

The retriever will read all the flags from the collection.

### Example:
```json
{
"flag": "new-admin-access",
"variations": {
"default_var": false,
"false_var": false,
"true_var": true
},
"defaultRule": {
"percentage": {
"false_var": 70,
"true_var": 30
}
}
}
```

## Configuration fields
To configure your mongodb retriever:

| Field | Description |
|------------------|-------------------------------------------------------------|
| **`Collection`** | Name of the collection where your flags are stored |
| **`Database`** | Name of the mongo database where the collection is located. |
| **`URI`** | Connection URI of your mongoDB instance. |
Binary file added website/static/docs/retrievers/mongodb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit bca8893

Please sign in to comment.