laika

command module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2018 License: MIT Imports: 9 Imported by: 0

README

Laika

CircleCI Coverage Status

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.

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":"secret"} 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.

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
package main

import (
	"log"

	"github.com/MEDIGO/laika/client"
)

func main() {
	c, err := client.NewClient(client.Config{
		Addr:        "127.0.0.1:8000",
		Username:    "my-username",
		Password:    "my-password",
		Environment: "prod",
	})

	if err != nil {
		log.Fatal(err)
	}

	if c.IsEnabled("my-awesome-feature", false) {
		log.Print("IT'S ALIVE!")
	} else {
		log.Print("Move along. Nothing to see here.")
	}
}

Developing

To develop Laika you need to have the following tools installed in your machine:

Then install all the Go and Javascript dependencies with:

$ make install

Build continuously the server and UI with:

$ make develop

And start hacking!

$ open http://localhost:8000

Testing

The whole test suite can be executed with:

$ make test

Some test require a MySQL instance, you can pass the configuration to them with the following environment variables:

LAIKA_TEST_MYSQL_HOST=localhost
LAIKA_TEST_MYSQL_PORT=3306
LAIKA_TEST_MYSQL_USERNAME=root
LAIKA_TEST_MYSQL_PASSWORD=root
LAIKA_TEST_MYSQL_DBNAME=test

Current state of the project

In the current release of Laika, it is possible to create feature flags and enable/disable them in the existing environments.

Wishlist
  • Specify country access (e.g. feature only enabled in Germany).
  • Specify user access with percentage (e.g. feature only enabled for 30% of the user base).
  • Have a field for environment creation on the web page.
  • History for flag status changes.

Copyright © 2016 MEDIGO GmbH.

Laika is licensed under the MIT License. See LICENSE for the full license text.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL