Feature Service
===============

The feature service is an easy way to acceptance test features as users. It is
not yet advisable for A/B testing, or rollout strategies.

Feature flags returned by ows-features are managed via https://www.split.io/

Please see the [Feature Flagging With SPLIT.IO Google Doc](https://docs.google.com/document/d/1Ozrj9gWn8W5U9L6MEpHGhi7o8L2Au0oyIJVKj6pifkA/edit) for instructions on how to use split.io to make feature flags (or 'splits' as they are know to split.io).

For questions - please use the #split-io Slack channel.


Getting Started
---------------

### Installation

The installation is very straightforward, but make sure you are using at least
python 3.6. If you use a Mac, you can install it using `brew`. If you use
Windows, just ask for a remote VM that has it installed for you.

**Because feature flags are now retrieved from split.io, you will need to make a
Systems ticket requesting a split.io API key and hyrdate this in a .env file**

```
cp .env.shadow .env
-- add your split.io key to the .env file
source .env

make pip_dev
```

### Running

When all dependencies have been installed, you can run the flask application
on your local instance by running:

```
make dev
```

You can optionally set a PORT environment variable to run on a port other than
8000:

```bash
PORT=5001 make dev
```

By using the development server, you will have access to specific features that
are not necessarily available in production, such as the exception tracer.

#### Docker

You can run a hot-reloading dev service, accessible from :8888:

```
make up_dev
```

Bring that down with:

```
make down_dev
```

Alternatively, you can build/run a deploy (uwsgi) service, accessible from :8889:

```
make up_deploy
```

Bring that down with:

```
make down_deploy
```


### Testing

```bash
make lint test_unit
```

To run the integration tests, first copy `tests/integration/.env.shadow` to `tests/integration/.env` and set values accordingly. Then run

```bash
$ dotenv -f tests/integration/.env run make test_integration 
```

To run with Docker with the deployed container, run:

```bash
# awsume to the `dev` AWS Account: `103233932089`
$ awsume dev
$ make docker_test_integration
```

To run with Docker with the locally built `deploy` container, run:

```bash
# awsume to the `dev` AWS Account: `103233932089`
$ awsume dev
$ make local_test_integration
```

NOTE: This command will hang on `Attaching to test-integration-1` for about 30 seconds. That's expected.

### Feature Name Selection
Choose a concise, but descriptive name for the feature flag. Don’t use its JIRA ticket number. For example: [VS-130 Create "Unmonetized Streams" Channel for Users](http://jira.theorchard.com/browse/VS-130)

GOOD: 
```
unmonetized_streams
```
EH:
```
unmonetized_streams_channel
```
BAD:
```
streams
```
```
for-users
```
```
VS-130
```
