Configuring match_fun in conn_opts fails to build release
tpitale opened this issue · comments
Is there a way to have an existing redix connection started and give it to NebulexRedisAdapter/Nebulex at runtime?
Background:
Because we can't really call code from within config.exs et al, this fails to build a release:
config :my_app, MyApp.Cache,
# config for NebulexRedisAdapter from config/prod.exs
conn_opts: [
url: System.get_env("REDIS_ENDPOINT"),
password: {System, :get_env, ["REDIS_TOKEN"]},
sync_connect: true,
socket_opts: [
customize_hostname_check: [
match_fun: :public_key.pkix_verify_hostname_match_fun(:https)
]
]
]
Specifically the match_fun
call to :public_key
Erlang module leads to mix release
returning an error:
** (Protocol.UndefinedError) protocol Enumerable not implemented for %Config.Provider{config_path: {:system, "RELEASE_SYS_CONFIG", ".config"}, extra_config: [kernel: [start_distribution: true]], providers: [{Config.Reader, {{:system, "RELEASE_ROOT", "/releases/0.1.0/runtime.exs"}, [env: :prod, target: :host, imports: :disabled]}}], prune_runtime_sys_config_after_boot: false, reboot_system_after_config: true, validate_compile_env: [{:retentions, [:plug_telemetry], {:ok, [level: :info]}}, {:mime, [:types], :error}]} of type Config.Provider (a struct). This protocol is implemented for the following type(s): Ecto.Adapters.SQL.Stream, Postgrex.Stream, DBConnection.Stream, DBConnection.PrepareStream, Timex.Interval, Jason.OrderedObject, HashSet, Range, Map, Function, List, Stream, Date.Range, HashDict, GenEvent.Stream, MapSet, File.Stream, IO.Stream
…
While this isn't a very good error, my only change was adding conn_opts for redis, and I was able to narrow it down.
Is it possible for match_fun
to be an MFA? I'm looking in the Redix docs and not finding anything.
Maybe I'll check the code.
I guess it's this config in Erlang: https://www.erlang.org/doc/man/ssl.html#type-customize_hostname_check, doesn't seem to take an MFA.
Maybe I need to add a config provider 🤔
Or otherwise I need to hijack the opts before they get to NebulexRedisAdapter.init