我正在尝试在苦艾酒中间件/3FunWithFlags.enabled?
回调中使用(ref fwf ),但出现以下错误:
(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
我没有尝试太多。我只是缩小了问题发生的范围。我猜中间件在创建:some_flag record
(或者可能是:fun_with_flags_cache
表)之前编译,然后因为没有记录/表而失败。
这个链接说:
它将标志信息存储在 Redis 或关系数据库(PostgreSQL 或 MySQL,带有 Ecto)中,用于跨不同节点的持久性和同步,但它还在 ETS 表中维护本地缓存以进行快速查找。当在一个节点上添加或切换标志时,其他节点会通过 PubSub 通知并重新加载其本地 ETS 缓存。
我已经尝试使用以下配置禁用 ETS:
config :fun_with_flags, :cache,
enabled: false,
但我没有工作。:(
这是我如何使用它的示例:
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
谢谢!