Basic Redis backend module to make flipping features on/off for individuals or named groups a snap
WARNING - NOT MAINTAINED
If available in Hex, the package can be installed as:
-
Add hyde to your list of dependencies in
mix.exs
:def deps do [{:hyde, "~> 0.0.1"}] end
-
Ensure hyde is started before your application:
def application do [applications: [:hyde]] end
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
{: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
{: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
{: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
- Move Redis client creation to initialization/lazy vs passing it in all the time