{"id":13563956,"url":"https://github.com/leorog/quarantine","last_synced_at":"2025-06-29T07:37:48.418Z","repository":{"id":57538522,"uuid":"192257564","full_name":"leorog/quarantine","owner":"leorog","description":"Tiny OTP application for feature toggles.","archived":false,"fork":false,"pushed_at":"2019-06-29T20:32:26.000Z","size":14,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-05-10T19:16:10.447Z","etag":null,"topics":["elixir","feature-flags","feature-toggles","otp","rollout"],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leorog.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-06-17T01:54:54.000Z","updated_at":"2025-01-28T07:49:30.000Z","dependencies_parsed_at":"2022-09-19T07:31:42.478Z","dependency_job_id":null,"html_url":"https://github.com/leorog/quarantine","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/leorog/quarantine","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leorog%2Fquarantine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leorog%2Fquarantine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leorog%2Fquarantine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leorog%2Fquarantine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leorog","download_url":"https://codeload.github.com/leorog/quarantine/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leorog%2Fquarantine/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262558532,"owners_count":23328552,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["elixir","feature-flags","feature-toggles","otp","rollout"],"created_at":"2024-08-01T13:01:25.011Z","updated_at":"2025-06-29T07:37:48.402Z","avatar_url":"https://github.com/leorog.png","language":"Elixir","funding_links":[],"categories":["Miscellaneous"],"sub_categories":[],"readme":"# Quarantine\n[![Build Status](https://travis-ci.org/leorog/quarantine.svg?branch=master)](https://travis-ci.org/leorog/quarantine)\n[![Quarantine Version](https://img.shields.io/hexpm/v/quarantine.svg)](https://hex.pm/packages/quarantine)\n\nQuarantine is a tiny OTP application for feature toggles.\n\nCurrently it supports two strategies:\n\n* `whitelist` list of ids that can access some feature\n* `percentage` compute a score from the given `id` check with `score \u003c= percentage`. Note that the combination of `feature` name and `id` produce a deterministic score\n\n## Setup\n\nAdd quarantine to your application deps\n\n```elixir\ndef deps do\n  [\n    {:quarantine, \"~\u003e 0.1.2\"}\n  ]\nend\n```\n\nYou can setup flags using config environment or provide a [Quarantine.Driver](lib/quarantine/driver.ex) to [fetch configuration from an external source](https://github.com/leorog/quarantine/tree/master#refresh-config-without-re-deploying-your-application)\n\nWhen hardcoded config is good enough you can provide it as below\n\n```elixir\nconfig :quarantine, \n   some_percentage_flag: 0.5,\n   some_whitelist_flag: [1, 2, 3]\n   other_whitelist_flag: [\"08362804-bdc0-11e8-9407-24750000045e\", \"9fbc6c6e-f2dd-4f9d-8944-b81dd5a25fed\"]\n```\n\n## Usage\n\nSimply call `enabled?/2` where you want to split the control flow\n\n```elixir\nQuarantine.enabled?(:some_percentage_flag, 1)\n=\u003e false\n\nQuarantine.enabled?(:some_percentage_flag, 2)\n=\u003e true\n\nQuarantine.enabled?(:some_whitelist_flag, 1)\n=\u003e true\n\nQuarantine.enabled?(:some_whitelist_flag, 9)\n=\u003e false\n```\n\nWhen using `percentage` you can check current ids distribution if needed with `scores/2` \n\n```elixir\nQuarantine.scores(:some_percentage_flag, [1, 2, 3])\n=\u003e  [{1, 0.9967498283360037},\n     {2, 0.18811322194247349},\n     {3, 0.30522621499961855}]\n```\n\n## Testing\n\nFlags can be enabled for a specific test with `Quarantine.Server.start_link/1`.\n\n```elixir\nQuarantine.Server.start_link(feature1: [1], feature2: [3,4])\n```\n\n## Refresh config without re-deploying your application\n\nTo do that you should provide an implementation of [Quarantine.Driver](lib/quarantine/driver.ex) that fetch flags configuration from a external source\n\nRedis Driver example:\n```elixir\ndefmodule RedisDriver do\n  @behaviour Quarantine.Driver\n\n  def get_flags() do\n    Redix.command!(:my_redix, [\"GET\", \"my_flags\"])\n  end\nend\n```\n\nS3 Driver example:\n```elixir\ndefmodule S3Driver do\n  @behaviour Quarantine.Driver\n\n  def get_flags() do\n    \"bucket\"\n    |\u003e ExAws.S3.get_object(\"path\")\n    |\u003e ExAws.request!()\n  end\nend\n```\n\nThen add it to `:quarantine` configuration:\n\n```elixir\nconfig :quarantine, \n   driver: RedisDriver,\n   poll_interval: 60_000 # in ms\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleorog%2Fquarantine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleorog%2Fquarantine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleorog%2Fquarantine/lists"}