Elixir SDK
Elixirv0.1.0
Terminal window
lib/my_app/application.ex
Installation
Section titled “Installation”Add flags_gg to your mix.exs dependencies:
defp deps do [ {:flags_gg, "~> 0.1"} ]endThen fetch dependencies:
mix deps.getQuick Start
Section titled “Quick Start”The SDK is built on a GenServer. Add it to your application’s supervision tree so the cache and background refresh start with your app:
def start(_type, _args) do children = [ {FlagsGG, project_id: "your-project-id", agent_id: "your-agent-id", environment_id: "your-environment-id"} ]
Supervisor.start_link(children, strategy: :one_for_one, name: MyApp.Supervisor)endThen check flags anywhere in your app:
if FlagsGG.enabled?("new-feature") do IO.puts("Feature is enabled!")end
# Get the full flag structflag = FlagsGG.is("new-feature")flag.enabled
# List all cached flagsfor flag <- FlagsGG.list() do IO.puts("#{flag.name}: #{flag.enabled}")endBatch Operations
Section titled “Batch Operations”# Returns %{name => enabled?} for the named flagsresults = FlagsGG.get_multiple(["feature-1", "feature-2"])
# True only if every named flag is enabledif FlagsGG.all_enabled?(["feature-1", "feature-2"]) do IO.puts("All enabled")end
# True if any named flag is enabledif FlagsGG.any_enabled?(["premium", "beta"]) do IO.puts("At least one enabled")end