I’m trying to use FunWithFlags.enabled?
(ref fwf) inside an absinthe middleware/3 callback but I got the following error:
(ArgumentError) argument error
(stdlib) :ets.lookup(:fun_with_flags_cache, :some_flag)
Stacktrace:
│ lib/fun_with_flags/store/cache.ex:35: FunWithFlags.Store.Cache.get/1
│ lib/fun_with_flags/store.ex:12: FunWithFlags.Store.lookup/1
│ lib/fun_with_flags.ex:77: FunWithFlags.enabled?/2
I haven’t tried too much. I just narrowed down where the issue is happening. I’m guessing the middleware compiles before the :some_flag record
(or maybe the :fun_with_flags_cache
table) is created and then failed because there is no record/table.
This link says:
It stores flag information in Redis or a relational DB (PostgreSQL or MySQL, with Ecto) for persistence and synchronization across different nodes, but it also maintains a local cache in an ETS table for fast lookups. When flags are added or toggled on a node, the other nodes are notified via PubSub and reload their local ETS caches.
I already tried to disable the ETS with the following config:
config :fun_with_flags, :cache,
enabled: false,
But I didn't work. :(
Here is an example of how I'm using it:
defmodule MyApp.Schema do
use Absinthe.Schema
...
def middleware(middleware, field, object) do
FunWithFlags.enabled?(:some_flag) # <-- (ArgumentError) argument error (stdlib) :ets.lookup...
...
end
end
Thanks!