quantum-elixir / quantum-core

:watch: Cron-like job scheduler for Elixir
https://hexdocs.pm/quantum/
Apache License 2.0
2.28k stars 148 forks source link

Quantum Child Specification Error in Elixir Application #607

Closed jaycdave88 closed 4 months ago

jaycdave88 commented 4 months ago

Hi,

version: {:quantum, "~> 3.5.3"}

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!

maennchen commented 4 months ago

A discussion is enough, please don’t double post.