jaycdave88

jaycdave88

Quantum Child Specification Error in Elixir Application

Hi,

versions:

  • {:quantum, "~> 3.5.3"}
  • elixir: "~> 1.14"

I’ve encountered an issue with integrating the Quantum scheduler into my Elixir application’s supervision tree. Despite following the documentation and ensuring that Quantum is correctly added as a child to the supervisor, I’m still facing an error related to the child_spec/1 function.

Here’s the error message I’m receiving:

Application featureflagservice exited: exited in: Featureflagservice.Application.start(:normal, [])
** (EXIT) an exception was raised:
    ** (ArgumentError) The module Quantum was given as a child to a supervisor
    but it does not implement child_spec/1.

This error persists even after specifying Quantum in the application’s supervision tree as follows:

children = [
  # ... other children ...
  {Quantum, [name: Featureflagservice.Scheduler]}
]

And here’s the relevant part of my config.exs where I define the Quantum jobs:

config :featureflagservice, Featureflagservice.Scheduler,
  jobs: [
    # Jobs configuration
    # Every 2 hours, set the feature flag to 1.0 for cartServiceFailure
    {"@every 2h", {Featureflagservice.FeatureFlags, :toggle_feature_flag, ["cartServiceFailure", 1.0]}},
    # Every 30 minutes, set the feature flag to 0.0 for cartServiceFailure
    {"@every 30m", {Featureflagservice.FeatureFlags, :toggle_feature_flag, ["cartServiceFailure", 0.0]}}
  ]

I’ve ensured that Quantum is included in my mix.exs dependencies and fetched with mix deps.get. My Elixir and OTP versions are compatible with the Quantum version I’m using.

Could anyone provide insights into what might be causing this issue or suggest a solution? Any help would be greatly appreciated.

Thank you!

First Post!

jaycdave88

jaycdave88

Full error:

feature-flag-service exited with code 1
feature-flag-service     | 14:56:12.884 [info] Migrations already up
feature-flag-service     | 14:56:13.268 [notice] Application featureflagservice exited: exited in: Featureflagservice.Application.start(:normal, [])
feature-flag-service     |     ** (EXIT) an exception was raised:
feature-flag-service     |         ** (ArgumentError) The module Quantum was given as a child to a supervisor
feature-flag-service     | but it does not implement child_spec/1.
feature-flag-service     | 
feature-flag-service     | If you own the given module, please define a child_spec/1 function
feature-flag-service     | that receives an argument and returns a child specification as a map.
feature-flag-service     | For example:
feature-flag-service     | 
feature-flag-service     |     def child_spec(opts) do
feature-flag-service     |       %{
feature-flag-service     |         id: __MODULE__,
feature-flag-service     |         start: {__MODULE__, :start_link, [opts]},
feature-flag-service     |         type: :worker,
feature-flag-service     |         restart: :permanent,
feature-flag-service     |         shutdown: 500
feature-flag-service     |       }
feature-flag-service     |     end
feature-flag-service     | 
feature-flag-service     | Note that "use Agent", "use GenServer" and so on automatically define
feature-flag-service     | this function for you.
feature-flag-service     | 
feature-flag-service     | However, if you don't own the given module and it doesn't implement
feature-flag-service     | child_spec/1, instead of passing the module name directly as a supervisor
feature-flag-service     | child, you will have to pass a child specification as a map:
feature-flag-service     | 
feature-flag-service     |     %{
feature-flag-service     |       id: Quantum,
feature-flag-service     |       start: {Quantum, :start_link, [arg1, arg2]}
feature-flag-service     |     }
feature-flag-service     | 
feature-flag-service     | See the Supervisor documentation for more information.
feature-flag-service     | 
feature-flag-service     |             (elixir 1.14.3) lib/supervisor.ex:701: Supervisor.init_child/1
feature-flag-service     |             (elixir 1.14.3) lib/enum.ex:1658: Enum."-map/2-lists^map/1-0-"/2
feature-flag-service     |             (elixir 1.14.3) lib/enum.ex:1658: Enum."-map/2-lists^map/1-0-"/2
feature-flag-service     |             (elixir 1.14.3) lib/supervisor.ex:687: Supervisor.init/2
feature-flag-service     |             (elixir 1.14.3) lib/supervisor.ex:617: Supervisor.start_link/2
feature-flag-service     |             (kernel 7.3.1.5) application_master.erl:277: :application_master.start_it_old/4```

Where Next?

Popular in Questions Top

dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
New
dokuzbir
Hello, I am trying to convert my lists to string without losing brackets.For start i have 3 map. They look like these buyer = %{ id: ...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New

Other popular topics Top

Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3268 119930 1237
New
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
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
yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
New
lk-geimfari
What is most correct way to open, read and parse JSON file with poison? For example if we have example.json file in root of some projec...
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
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
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New

We're in Beta

About us Mission Statement