Feature flipper in elixir

one way of making feature flipper with elixir could be with application config and macros.
so here are the basic
you make config

  config :production,
    :feature, :on


then you make macro

defmacro feature()do
  activeEnvironment=Application.get_env(:environment,:active)
  if Application.get_env(activeEnvironment,:active) == :on do
    quote do
      #feature code goes here or maybe you can pass it as argument or what not
      
    end
  end
end

so why this thing might be better than no macro code?
if you want to make realtime system you might want to avoid constant function calls on critical path of your application or to just precompile some stuff like addresses that you would use over and over.

Leave a Comment