Skip to content

Commit ebc96f8

Browse files
Initial implementation
1 parent 87a38c3 commit ebc96f8

File tree

14 files changed

+2288
-118
lines changed

14 files changed

+2288
-118
lines changed

README.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Feature Flags
2+
3+
A dynamic feature flags library for Node.js. This library gives you fine-grained control over rolling out and testing new features.
4+
5+
This implementation is largely based on [Feature Toggles](https://twitter.github.io/finagle/guide/Configuration.html#feature-toggles) in [Twitter's Finagle framework](https://github.com/twitter/finagle).
6+
7+
## Install
8+
9+
This feature flags library has a peer dependency on `@creditkarma/dynamic-config`.
10+
11+
```sh
12+
$ npm install --save @creditkarma/dynamic-config
13+
$ npm install --save @creditkarma/feature-flags
14+
```
15+
16+
## Usage
17+
18+
### Dynamic Config
19+
20+
[DynamicConfig](https://github.com/creditkarma/dynamic-config) is a pluggable config library for Node.js that allows for runtime changes to config values.
21+
22+
### Flag Schema
23+
24+
```json
25+
{
26+
"\$schema": "http://json-schema.org/draft-04/schema#",
27+
"type": "object",
28+
"properties": {
29+
"toggles": {
30+
"type": "array",
31+
"items": {
32+
"type": "object",
33+
"properties": {
34+
"id": {
35+
"type": "string"
36+
},
37+
"description": {
38+
"type": "string"
39+
},
40+
"fraction": {
41+
"type": "number",
42+
"minimum": 0.0,
43+
"maximum": 1.0,
44+
"exclusiveMinimum": false,
45+
"exclusiveMaxmimum": false
46+
},
47+
"comment": { "type": "string" }
48+
},
49+
"required": [ "id", "fraction" ]
50+
}
51+
}
52+
},
53+
"required": [ "toggles" ]
54+
}
55+
```
56+
57+
```json
58+
{
59+
"toggles": [
60+
{
61+
"id": "com.example.service.UseNewBackend",
62+
"description": "Use new backend code",
63+
"fraction": 0.1,
64+
}
65+
]
66+
}
67+
```

docker-compose.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: '2'
2+
services:
3+
consul:
4+
image: consul:1.1.0
5+
volumes:
6+
- $PWD/consuldata:/tmp/consuldata
7+
ports:
8+
- "8410:8400"
9+
- "8510:8500"
10+
- "8610:8600"
11+
environment:
12+
- "CONSUL_LOCAL_CONFIG={\"disable_update_check\": true}"
13+
- "CONSUL_BIND_INTERFACE=eth0"
14+
command: "consul agent -dev -client 0.0.0.0 -server -data-dir=/tmp/consuldata -bootstrap-expect=1"

0 commit comments

Comments
 (0)