{"id":15063632,"url":"https://github.com/open-feature/elixir-sdk","last_synced_at":"2025-04-10T11:25:13.983Z","repository":{"id":250511591,"uuid":"834667489","full_name":"open-feature/elixir-sdk","owner":"open-feature","description":"Elixir SDK for OpenFeature","archived":false,"fork":false,"pushed_at":"2024-10-17T18:21:52.000Z","size":63,"stargazers_count":17,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-24T10:12:03.406Z","etag":null,"topics":["elixir","openfeature","sdk"],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/open-feature.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-28T01:39:45.000Z","updated_at":"2025-03-18T07:18:48.000Z","dependencies_parsed_at":"2024-10-19T23:16:54.024Z","dependency_job_id":"e424c85d-156d-4aa6-a3f7-06633f60e86c","html_url":"https://github.com/open-feature/elixir-sdk","commit_stats":null,"previous_names":["ejscunha/elixir-open-feature-sdk","open-feature/elixir-sdk"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-feature%2Felixir-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-feature%2Felixir-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-feature%2Felixir-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/open-feature%2Felixir-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/open-feature","download_url":"https://codeload.github.com/open-feature/elixir-sdk/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248208616,"owners_count":21065203,"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","openfeature","sdk"],"created_at":"2024-09-25T00:05:07.939Z","updated_at":"2025-04-10T11:25:13.967Z","avatar_url":"https://github.com/open-feature.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- markdownlint-disable MD033 --\u003e\n\u003c!-- x-hide-in-docs-start --\u003e\n\u003cp align=\"center\"\u003e\n  \u003cpicture\u003e\n    \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://raw.githubusercontent.com/open-feature/community/0e23508c163a6a1ac8c0ced3e4bd78faafe627c7/assets/logo/horizontal/white/openfeature-horizontal-white.svg\" /\u003e\n    \u003cimg align=\"center\" alt=\"OpenFeature Logo\" src=\"https://raw.githubusercontent.com/open-feature/community/0e23508c163a6a1ac8c0ced3e4bd78faafe627c7/assets/logo/horizontal/black/openfeature-horizontal-black.svg\" /\u003e\n  \u003c/picture\u003e\n\u003c/p\u003e\n\n\u003ch2 align=\"center\"\u003eOpenFeature Elixir SDK\u003c/h2\u003e\n\n\u003c!-- x-hide-in-docs-end --\u003e\n\u003c!-- The 'github-badges' class is used in the docs --\u003e\n\u003cp align=\"center\" class=\"github-badges\"\u003e\n  \u003ca href=\"https://github.com/open-feature/spec/releases/tag/v0.7.0\"\u003e\n    \u003cimg alt=\"Specification\" src=\"https://img.shields.io/static/v1?label=specification\u0026message=v0.7.0\u0026color=yellow\u0026style=for-the-badge\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- x-release-please-start-version --\u003e\n\n  \u003ca href=\"https://github.com/open-feature/elixir-sdk/releases/tag/v0.1.1\"\u003e\n    \u003cimg alt=\"Release\" src=\"https://img.shields.io/static/v1?label=release\u0026message=v0.1.1\u0026color=blue\u0026style=for-the-badge\" /\u003e\n  \u003c/a\u003e\n\n  \u003c!-- x-release-please-end --\u003e\n  \u003cbr/\u003e\n  \u003ca href=\"https://hexdocs.pm/open_feature/\"\u003e\n    \u003cimg alt=\"Docs\" src=\"https://img.shields.io/badge/docs-hexpm-blue.svg\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/open-feature/elixir-sdk/blob/main/LICENSE.md\"\u003e\n    \u003cimg alt=\"License\" src=\"https://img.shields.io/hexpm/l/req.svg\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/open-feature/elixir-sdk/actions/workflows/ci.yml\"\u003e\n    \u003cimg alt=\"CI\" src=\"https://github.com/open-feature/elixir-sdk/actions/workflows/ci.yml/badge.svg\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://bestpractices.coreinfrastructure.org/projects/6601\"\u003e\n    \u003cimg alt=\"CII Best Practices\" src=\"https://bestpractices.coreinfrastructure.org/projects/6601/badge\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\u003c!-- x-hide-in-docs-start --\u003e\n\n[OpenFeature](https://openfeature.dev) is an open specification that provides a vendor-agnostic, community-driven API for feature flagging that works with your favorite feature flag management tool or in-house solution.\n\n\u003c!-- x-hide-in-docs-end --\u003e\n## 🚀 Quick start\n\n### Requirements\n\nIt requires Elixir 1.14 or greater to run.\n\n### Install\n\nThe package can be installed by adding `open_feature` to your list of dependencies\nin `mix.exs`:\n\n```elixir\ndef deps do\n  [{:open_feature, \"~\u003e 0.1\"}]\nend\n```\n\n### Usage\n\n```elixir\nprovider = %OpenFeature.Provider.InMemory{\n  flags: %{\n    \"v2_enabled\" =\u003e %{\n      disabled: false,\n      default_variant: \"on\",\n      variants: %{\n        \"on\" =\u003e true,\n        \"off\" =\u003e false,\n      }\n    }\n  }\n}\n{:ok, provider} = OpenFeature.set_provider(provider)\nclient = OpenFeature.get_client()\nv2_enabled = OpenFeature.Client.get_boolean_value(client, \"v2_enabled\", false)\n```\n\n### API Reference\n\nFor details, including API documentation, see the respective [Hex docs](https://hexdocs.pm/open_feature/).\n\n## 🌟 Features\n\n| Status | Features                                                            | Description                                                                                                                                                  |\n| ------ | --------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ⚠️      | [Providers](#providers)                                             | Integrate with a commercial, open source, or in-house feature management tool.                                                                               |\n| ✅      | [Targeting](#targeting)                                             | Contextually-aware flag evaluation using [evaluation context](https://openfeature.dev/docs/reference/concepts/evaluation-context).                           |\n| ✅      | [Hooks](#hooks)                                                     | Add functionality to various stages of the flag evaluation life-cycle.                                                                                       |\n| ✅      | [Logging](#logging)                                                 | Integrate with popular logging packages.                                                                                                                     |\n| ✅      | [Domains](#domains)                                                 | Logically bind clients with providers.                                                                                                                       |\n| ✅      | [Eventing](#eventing)                                               | React to state changes in the provider or flag management system.                                                                                            |\n| ✅      | [Shutdown](#shutdown)                                               | Gracefully clean up a provider during application shutdown.                                                                                                  |\n| ✅      | [Extending](#extending)                                             | Extend OpenFeature with custom providers.                                                                                                          |\n\n\u003csub\u003eImplemented: ✅ | In-progress: ⚠️ | Not implemented yet: ❌\u003c/sub\u003e\n\n### Providers\n\n[Providers](https://openfeature.dev/docs/reference/concepts/provider) are an abstraction between a flag management system and the OpenFeature SDK.\nLook [here](https://openfeature.dev/ecosystem?instant_search%5BrefinementList%5D%5Btype%5D%5B0%5D=Provider\u0026instant_search%5BrefinementList%5D%5Btechnology%5D%5B0%5D=Elixir) for a complete list of available providers.\nIf the provider you're looking for hasn't been created yet, see the [develop a provider](#develop-a-provider) section to learn how to build it yourself.\n\nOnce you've added a provider as a dependency, it can be registered with OpenFeature like this:\n\n```elixir\nprovider = %OpenFeature.Provider.InMemory{\n  flags: %{\n    \"v2_enabled\" =\u003e %{\n      disabled: false,\n      default_variant: \"one\",\n      variants: %{\n        \"on\" =\u003e true,\n        \"off\" =\u003e false\n      }\n    }\n  }\n}\n{:ok, provider} = OpenFeature.set_provider(provider)\n```\n\nIn some situations, it may be beneficial to register multiple providers in the same application.\nThis is possible using [domains](#domain), which is covered in more detail below.\n\n### Targeting\n\nSometimes, the value of a flag must consider some dynamic criteria about the application or user, such as the user's location, IP, email address, or the server's location.\nIn OpenFeature, we refer to this as [targeting](https://openfeature.dev/specification/glossary#targeting).\nIf the flag management system you're using supports targeting, you can provide the input data using the [evaluation context](https://openfeature.dev/docs/reference/concepts/evaluation-context).\n\n```elixir\n# set a value to the global context\nOpenFeature.set_global_context(%{region: \"us-east-1\"})\n\n# set a value to the client context\nclient = OpenFeature.get_client() |\u003e OpenFeature.Client.set_context(%{region: \"us-east-1\"})\n\n# set a value to the invocation context\nflag_value = OpenFeature.Client.get_boolean_value(client, \"some-flag\", flag, context: %{region: \"us-east-1\"})\n```\n\n### Hooks\n\n[Hooks](https://openfeature.dev/docs/reference/concepts/hooks) allow for custom logic to be added at well-defined points of the flag evaluation life-cycle.\nLook [here](https://openfeature.dev/ecosystem/?instant_search%5BrefinementList%5D%5Btype%5D%5B0%5D=Hook\u0026instant_search%5BrefinementList%5D%5Btechnology%5D%5B0%5D=Elixir) for a complete list of available hooks.\n\nOnce you've added a hook as a dependency, it can be registered at the client or flag invocation level.\n\n```elixir\n## add a hook on this client, to run on all evaluations made by this client\nclient = OpenFeature.Client.add_hooks(client, [%OpenFeature.Hook{}])\n\n## add a hook for this evaluation only\nflag_value = OpenFeature.Client.get_boolean_value(client, flag_key, false, hooks: [%OpenFeature.Hook{}]);\n```\n\n### Logging\n\nThe Elixir SDK uses the default Elixir Logger.\n\n### Domains\n\nClients can be assigned to a domain. A domain is a logical identifier which can be used to associate clients with a particular provider.\nIf a domain has no associated provider, the default provider is used.\n\n```elixir\nprovider = %OpenFeature.Provider.InMemory{\n  flags: %{\n    \"v2_enabled\" =\u003e %{\n      disabled: false,\n      default_variant: \"default\",\n      variants: %{\n        \"default\" =\u003e true\n      }\n    }\n  }\n}\n\n# registering the default provider\n{:ok, _provider} = OpenFeature.set_provider(provider)\n# registering a provider to a domain\n{:ok, _provider} = OpenFeature.set_provider(\"my-domain\", provider)\n\n# A client bound to the default provider\ndefault_client = OpenFeature.get_client()\n# A client bound to the CachedProvider provider\ndomain_client = OpenFeature.get_client(\"my-domain\")\n```\n\n### Eventing\n\nEvents allow you to react to state changes in the provider or underlying flag management system, such as flag definition changes, provider readiness, or error conditions.\nInitialization events (`PROVIDER_READY` on success, `PROVIDER_ERROR` on failure) are dispatched for every provider.\nSome providers support additional events, such as `PROVIDER_CONFIGURATION_CHANGED`.\n\nPlease refer to the documentation of the provider you're using to see what events are supported.\n\n```elixir\n# add an event handler to a client\nOpenFeature.Client.add_event_handler(client, :configuration_changed, fn event_details -\u003e\n  # do something when the provider's flag settings change\nend)\n```\n\n### Shutdown\n\nThe OpenFeature API provides a close function to perform a cleanup of all registered providers.\nThis should only be called when your application is in the process of shutting down.\n\n```elixir\nOpenFeature.shutdown()\n```\n\n## Extending\n\n### Develop a provider\n\nTo develop a provider, you need to create a new project and include the OpenFeature SDK as a dependency.\nThis can be a new repository or included in [the existing contrib repository](https://github.com/open-feature/elixir-sdk-contrib) available under the OpenFeature organization.\nYou’ll then need to write the provider by implementing the `OpenFeature.Provider` behaviour exported by the OpenFeature SDK.\n\n```elixir\ndefmodule OpenFeature.Provider.NoOp do\n  alias OpenFeature.ResolutionDetails\n\n  @behaviour OpenFeature.Provider\n\n  defstruct name: \"NoOp\", domain: nil, state: :not_ready, hooks: []\n\n  def initialize(provider, domain, _evaluation_context), do: {:ok, %{provider | state: :ready, domain: domain}}\n  def shutdown(_provider), do: :ok\n\n  def resolve_boolean_value(_provider, _key, default, _context), do: {:ok, %ResolutionDetails{value: default}}\n  def resolve_string_value(_provider, _key, default, _context), do: {:ok, %ResolutionDetails{value: default}}\n  def resolve_number_value(_provider, _key, default, _context), do: {:ok, %ResolutionDetails{value: default}}\n  def resolve_map_value(_provider, _key, default, _context), do: {:ok, %ResolutionDetails{value: default}}\nend\n\n```\n\n\u003e Built a new provider? [Let us know](https://github.com/open-feature/openfeature.dev/issues/new?assignees=\u0026labels=provider\u0026projects=\u0026template=document-provider.yaml\u0026title=%5BProvider%5D%3A+) so we can add it to the docs!\n\n\u003c!-- x-hide-in-docs-start --\u003e\n## ⭐️ Support the project\n\n- Give this repo a ⭐️!\n- Follow us on social media:\n  - Twitter: [@openfeature](https://twitter.com/openfeature)\n  - LinkedIn: [OpenFeature](https://www.linkedin.com/company/openfeature/)\n- Join us on [Slack](https://cloud-native.slack.com/archives/C0344AANLA1)\n- For more, check out our [community page](https://openfeature.dev/community/)\n\n## 🤝 Contributing\n\nInterested in contributing? Great, we'd love your help! To get started, take a look at the [CONTRIBUTING](CONTRIBUTING.md) guide.\n\n### Thanks to everyone who has already contributed\n\n\u003ca href=\"https://github.com/open-feature/elixir-sdk/graphs/contributors\"\u003e\n  \u003cimg src=\"https://contrib.rocks/image?repo=open-feature/elixir-sdk\" alt=\"Pictures of the folks who have contributed to the project\" /\u003e\n\u003c/a\u003e\n\n\nMade with [contrib.rocks](https://contrib.rocks).\n\u003c!-- x-hide-in-docs-end --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopen-feature%2Felixir-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopen-feature%2Felixir-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopen-feature%2Felixir-sdk/lists"}