<commit_before># Laika

[![CircleCI](https://circleci.com/gh/MEDIGO/laika.svg?style=shield)](https://circleci.com/gh/MEDIGO/laika) [![Coverage Status](https://coveralls.io/repos/github/MEDIGO/laika/badge.svg)](https://coveralls.io/github/MEDIGO/laika)

Laika is a feature flag/feature toggle service, written in Go, that allows the creation of flags and their activation/deactivation for specific environments. This way it is possible to control in which environments each feature is available. For instance, when a new feature is developed and released, it would make sense if it was only made available, at first, in a testing or Q&A environment, and only later in production. With Laika this can be achieved by simply going to a web page, selecting the feature, and changing its status on the desired environments.

Using Laika in a project thus allows for fast and continuous feature release and deployment.

`laika-php` is a PHP library that handles communication with Laika's API. You can get it [here](https://github.com/MEDIGO/laika-php).

## API Reference

Laika uses CQRS, the query endpoints are as follows.

| Method  | Endpoint                  | Description                |
| ------- | ------------------------- | -------------------------- |
| `GET`   | `/api/health`             | Check the service health   |
| `GET`   | `/api/features`           | List all features          |
| `GET`   | `/api/features/:name`     | Get a feature by name      |
| `GET`   | `/api/environments`       | List all environments      |

The command endpoint is for manipulating data.

| Method  | Endpoint                          | Example body                                                   | Description               |
| ------- | --------------------------------- | -------------------------------------------------------------- | ------------------------- |
| `POST`  | `/api/events/environment_created` | `{"name":"staging"}`                                           | Create a new environment. |
| `POST`  | `/api/events/feature_created`     | `{"name":"feature1"}`                                          | Create a new feature.     |
| `POST`  | `/api/events/user`                | `{"username":"admin","password":"<PASSWORD>"}`                     | Create a new user.        |
| `POST`  | `/api/events/feature_toggled`     | `{"feature":"feature1","environment":"staging","status":true}` | Toggle a feature.         |
| `POST`  | `/api/events/feature_deleted`     | `{"name":"feature1"}`                                          | Delete a feature.         |
| `POST`  | `/api/events/environments_ordered`| `{"order":["dev","staging"]}`                                  | Change env display order. |
| `POST`  | `/api/events/environment_deleted` | `{"name":"staging"}`                                           | Delete an environment.    |

## Client

Laika contains a polling HTTP client that allows to easily check for enabled/disabled features on Go code. It can be found in the `client` package. While Laika uses the `vendor` directory to store external dependencies, `client` can be imported without any vendoring.

### Install

```
$ go get -u github.com/MEDIGO/laika/client
```

### Usage

```go
package main

import (
	"log"
<commit_msg>Fix readme typo<commit_after># Laika

[![CircleCI](https://circleci.com/gh/MEDIGO/laika.svg?style=shield)](https://circleci.com/gh/MEDIGO/laika) [![Coverage Status](https://coveralls.io/repos/github/MEDIGO/laika/badge.svg)](https://coveralls.io/github/MEDIGO/laika)

Laika is a feature flag/feature toggle service, written in Go, that allows the creation of flags and their activation/deactivation for specific environments. This way it is possible to control in which environments each feature is available. For instance, when a new feature is developed and released, it would make sense if it was only made available, at first, in a testing or Q&A environment, and only later in production. With Laika this can be achieved by simply going to a web page, selecting the feature, and changing its status on the desired environments.

Using Laika in a project thus allows for fast and continuous feature release and deployment.

`laika-php` is a PHP library that handles communication with Laika's API. You can get it [here](https://github.com/MEDIGO/laika-php).

## API Reference

Laika uses CQRS, the query endpoints are as follows.

| Method  | Endpoint                  | Description                |
| ------- | ------------------------- | -------------------------- |
| `GET`   | `/api/health`             | Check the service health   |
| `GET`   | `/api/features`           | List all features          |
| `GET`   | `/api/features/:name`     | Get a feature by name      |
| `GET`   | `/api/environments`       | List all environments      |

The command endpoint is for manipulating data.

| Method  | Endpoint                          | Example body                                                   | Description               |
| ------- | --------------------------------- | -------------------------------------------------------------- | ------------------------- |
| `POST`  | `/api/events/environment_created` | `{"name":"staging"}`                                           | Create a new environment. |
| `POST`  | `/api/events/feature_created`     | `{"name":"feature1"}`                                          | Create a new feature.     |
| `POST`  | `/api/events/user_created`        | `{"username":"admin","password":"<PASSWORD>"}`                     | Create a new user.        |
| `POST`  | `/api/events/feature_toggled`     | `{"feature":"feature1","environment":"staging","status":true}` | Toggle a feature.         |
| `POST`  | `/api/events/feature_deleted`     | `{"name":"feature1"}`                                          | Delete a feature.         |
| `POST`  | `/api/events/environments_ordered`| `{"order":["dev","staging"]}`                                  | Change env display order. |
| `POST`  | `/api/events/environment_deleted` | `{"name":"staging"}`                                           | Delete an environment.    |

## Client

Laika contains a polling HTTP client that allows to easily check for enabled/disabled features on Go code. It can be found in the `client` package. While Laika uses the `vendor` directory to store external dependencies, `client` can be imported without any vendoring.

### Install

```
$ go get -u github.com/MEDIGO/laika/client
```

### Usage

```go
package main

import (
	"log"

{'fraction_non_alphanumeric': 0.16983445738810546, 'fraction_numerical': 0.0009196811771919068, 'mean_word_length': 1.9142474318892362, 'pattern_counts': {'":': 20, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 22, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2663770', 'n_tokens_mistral': 1680, 'n_tokens_neox': 1646, 'n_words': 558}