catra

catra

ArgumentError :ets.lookup in Absinthe Middleware using FunWithFlags

I’m trying to use FunWithFlags.enabled? (ref fwf) inside an absinthe middleware 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 that 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

So I’m guessing one option could be disable the ETS with the following config:

config :fun_with_flags, :cache,
  enabled: false,
  ttl: 900

But we lost all of the benefits of the cache.

Anyway, Any thought are welcome. Thanks in advance.
Thanks! :smiley:

Note: It doesn’t work adding the config. :frowning:

First Post!

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

Can you show how you are using it?

Most Liked

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

Gotcha.

Yeah the issue here is that this function is actually run at compile time. This means that your ets tables are likely not loaded. Using the persistent_term schema backend would probably help (in that it will refresh the value at runtime), but I think this still runs at compile time to do a check.

Last Post!

catra

catra

Hey @benwilson512 Thanks for reply. We ended using an env variable in the middle function and inside the middleware module we were able to use FeatureFlags. BTW, I’m enjoying reading you book, thank you for writing it. Such a gem for GraphQL API crafters.

Where Next?

Popular in Questions Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New

Other popular topics Top

vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 55125 245
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New

We're in Beta

About us Mission Statement