Error when configuring like examples
kyleboe opened this issue · comments
Elixir 1.12.3
Phoenix 1.5.12
Vapor 0.10.0
I haven't dug into why this error is now happening but when configuring like the example here:
defmodule VaporExample.Config do
use Vapor.Planner
dotenv()
config :db, env([
{:url, "DB_URL"},
{:name, "DB_NAME"},
{:pool_size, "DB_POOL_SIZE", default: 10, map: &String.to_integer/1},
])
config :web, env([
{:port, "PORT", map: &String.to_integer/1},
])
config :kafka, VaporExample.Kafka
end
defmodule VaporExample.Application do
use Application
def start(_type, _args) do
config = Vapor.load!(VaporExample.Config)
children = [
{VaporExampleWeb.Endpoint, config.web},
{VaporExample.Repo, config.db},
{VaporExample.Kafka, config.kafka},
]
opts = [strategy: :one_for_one, name: VaporExample.Supervisor]
Supervisor.start_link(children, opts)
end
end
I get the following error:
(FunctionClauseError) no function clause matching in Keyword.get/3
Turns out, the issue is resolved by changing the children configuration lines to first convert to a Keyword List instead of a Map like so:
{VaporExampleWeb.Endpoint, Map.to_list(config.web)},
{VaporExample.Repo, Map.to_list(config.db)},
A solution might be adding a function like Vapor.load_list!()
to load the config as a Keyword List. Thoughts?