ProductPromotion
Logo

Elixir

made by https://0x3d.site

GitHub - leorog/quarantine: Tiny OTP application for feature toggles.
Tiny OTP application for feature toggles. Contribute to leorog/quarantine development by creating an account on GitHub.
Visit Site

GitHub - leorog/quarantine: Tiny OTP application for feature toggles.

GitHub - leorog/quarantine: Tiny OTP application for feature toggles.

Quarantine

Build Status Quarantine Version

Quarantine is a tiny OTP application for feature toggles.

Currently it supports two strategies:

  • whitelist list of ids that can access some feature
  • percentage compute a score from the given id check with score <= percentage. Note that the combination of feature name and id produce a deterministic score

Setup

Add quarantine to your application deps

def deps do
  [
    {:quarantine, "~> 0.1.2"}
  ]
end

You can setup flags using config environment or provide a Quarantine.Driver to fetch configuration from an external source

When hardcoded config is good enough you can provide it as below

config :quarantine, 
   some_percentage_flag: 0.5,
   some_whitelist_flag: [1, 2, 3]
   other_whitelist_flag: ["08362804-bdc0-11e8-9407-24750000045e", "9fbc6c6e-f2dd-4f9d-8944-b81dd5a25fed"]

Usage

Simply call enabled?/2 where you want to split the control flow

Quarantine.enabled?(:some_percentage_flag, 1)
=> false

Quarantine.enabled?(:some_percentage_flag, 2)
=> true

Quarantine.enabled?(:some_whitelist_flag, 1)
=> true

Quarantine.enabled?(:some_whitelist_flag, 9)
=> false

When using percentage you can check current ids distribution if needed with scores/2

Quarantine.scores(:some_percentage_flag, [1, 2, 3])
=>  [{1, 0.9967498283360037},
     {2, 0.18811322194247349},
     {3, 0.30522621499961855}]

Testing

Flags can be enabled for a specific test with Quarantine.Server.start_link/1.

Quarantine.Server.start_link(feature1: [1], feature2: [3,4])

Refresh config without re-deploying your application

To do that you should provide an implementation of Quarantine.Driver that fetch flags configuration from a external source

Redis Driver example:

defmodule RedisDriver do
  @behaviour Quarantine.Driver

  def get_flags() do
    Redix.command!(:my_redix, ["GET", "my_flags"])
  end
end

S3 Driver example:

defmodule S3Driver do
  @behaviour Quarantine.Driver

  def get_flags() do
    "bucket"
    |> ExAws.S3.get_object("path")
    |> ExAws.request!()
  end
end

Then add it to :quarantine configuration:

config :quarantine, 
   driver: RedisDriver,
   poll_interval: 60_000 # in ms

Articles
to learn more about the elixir concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here 🔥.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here 🔥.

Queries
or most google FAQ's about Elixir.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory