tompave / fun_with_flags

Feature Flags/Toggles for Elixir
https://hexdocs.pm/fun_with_flags/FunWithFlags.html
MIT License
1.08k stars 79 forks source link

low priority feature req - automatically remove stale flags #173

Closed ghost closed 3 months ago

ghost commented 7 months ago

keep track of uses of a given flag using simple metric system + automatically delete/remove flags that haven't been referenced after a stale interval

tompave commented 3 months ago

I see how this could be useful, but I don't think that it should be added to FWF as a feature. This is because of a few reasons:

  1. FWF aims to be simple, and do one thing well.
  2. Adding a usage-tracking system and increment some counter (writing data somewhere) every time a flag is queried is going to have a performance overhead. This needs to be understood before adding something of this sort. I wonder if this could be done in-memory, without counter persistence (therefore, with less overhead), but then the usage tracking would become unreliable.
  3. This is something that can be easily added in application code with a wrapper for FWF, and even released as an extension on Hex. For example, your application could use a facade module that wraps FWF and its enabled? function, increments the counter with each call, and then runs some sweeper GenServer that periodically deletes stale flags.