🚥 Feature flipping for the Elixir world
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bench
lib
test
.formatter.exs
.gitignore
.travis.yml
CHANGELOG.md
LICENSE.txt
README.md
mix.exs
mix.lock

README.md

Flippant

Build Status Coverage Status Hex version Inline docs

Flippant is a libary for feature toggling in Elixir applications

Installation

  1. Add flippant to your list of dependencies in mix.exs:
def deps do
  [{:flippant, "~> 0.3"}]
end
  1. Add an adapter such as redix for Redis or postgrex for Postgres:
def deps do
  [{:redix, "~> 0.7"}]
end
  1. Set an adapter within your config.exs:
config :flippant,
       adapter: Flippant.Adapter.Redis,
       redis_opts: [url: System.get_env("REDIS_URL"), name: :flippant],
       set_key: "flippant-features"

Usage

Complete documentation is available online, but here is a breif overview:

Features are comprised of groups, and rules. Your application defines named groups, and you set rules to specify which groups are enabled for a particular feature. When it comes time to check if a feature is enabled for a particular actor (i.e. user or account), all the groups for a feature are evaluated. If the actor belongs to any of the groups then the feature is enabled.

All interaction happens directly through the Flippant module.

Define some basic groups:

Flippant.register("staff", fn %User{staff?: staff?}, _ -> staff?)
Flippant.register("testers", fn %User{id: id}, ids -> id in ids end)

Set a few rules for the "search" feature:

Flippant.enable("search", "staff")
Flippant.enable("search", "testers", [1818, 1819])

Check if the current user has access to a feature:

Flippant.enabled?("search", %User{id: 1817, staff?: false}) #=> true
Flippant.enabled?("search", %User{id: 1818, staff?: false}) #=> false
Flippant.enabled?("search", %User{id: 1820, staff?: true}) #=> true

License

MIT License, see LICENSE.txt for details.