Skip to content

beautifulcode/hyde

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mr. Hyde

Hyde

Feature Toggles for Elixir

Basic Redis backend module to make flipping features on/off for individuals or named groups a snap

WARNING - NOT MAINTAINED

Installation

If available in Hex, the package can be installed as:

  1. Add hyde to your list of dependencies in mix.exs:

    def deps do [{:hyde, "~> 0.0.1"}] end

  2. Ensure hyde is started before your application:

    def application do [applications: [:hyde]] end

Usage

Hyde is a convenience wrapper around ExRedis that exposes basic toggling capabilities by checking if a feature is active? using:

  • a global feature name
  • custom unique (user) id
  • the name of a group.

Hyde.active? will return {:ok, true} or false

Global

{:ok, client} = Exredis.start_link

if Hyde.active?(client, :my_feature) do
  # Do Feature Code
end

case Hyde.active?(client, :my_feature) do
  {:ok, true} -> 
    # Do Feature Code
  false ->
    # Do Nada
end

# Turn on a feature for all
client |> Hyde.activate(:my_feature)

# Query a feature for all
client |> Hyde.active?(:my_feature) 
#true

client |> Hyde.inactive?(:my_feature) 
#false

ID Based

{:ok, user} = YourApp.User()
{:ok, client} = Exredis.start_link

if Hyde.active?(client, :my_feature, user.id) do
  # Do Feature Code
end

# Turn on a feature for single user
client |> Hyde.activate(:my_feature, user.id)

# Query a feature for single user
client |> Hyde.active?(:my_feature, user.id) 
#true

client |> Hyde.inactive?(:my_feature, user.id) 
#false

Named Group Based

{:ok, user} = YourApp.User()
{:ok, client} = Exredis.start_link

if Hyde.active?(client, :my_feature, :admins) do
  # Do Feature Code
end

# Turn on a feature for single user
client |> Hyde.activate(:my_feature, :admins)

# Query a feature for single user
client |> Hyde.active?(:my_feature, :admins) 
#true

client |> Hyde.inactive?(:my_feature, :admins) 
#false

TODO

  • Move Redis client creation to initialization/lazy vs passing it in all the time

About

Elixir Feature Toggles - Basic Redis backed API for toggling features for one or groups of users

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages