Is there a way to remove key of Keyword in config?

In my config, Oban queue is set.

config :my_app, Oban, queue: [report: 5]

I want to remove the queue at runtime with runtime.exs.

config :my_app, Oban, queue: []

But it doesn’t remove report queue, because it just deep merge Keyword.

> Application.get(:my_app, Oban)
[
  queues: [report: 5]
]

Conflicting keys are overridden by the ones specified in opts , unless they are keywords, which are deep merged recursively.

https://hexdocs.pm/elixir/Config.html#config/3

Is there a way to remove key of Keyword in config?

No, there’s not.

Seems like Oban allows for an extended configuration of queues events: [limit: 50, paused: true], so maybe you could configure the queue to be paused.

1 Like

Oh, thanks a lot!

You can use queues: false To disable all queues, but configuration is deep merged. I recommend putting the entire queue config in runtime and using a conditional there.

2 Likes

Oh that would be great!