Packages
ash_oban
0.4.5
0.8.10
0.8.9
0.8.8
0.8.7
0.8.6
0.8.5
0.8.4
0.8.3
0.8.2
0.8.1
0.8.0-rc.1
0.8.0-rc.0
0.7.2
0.7.1
0.7.0
0.6.0
0.5.1
0.5.0
0.4.12
0.4.11
0.4.10
0.4.9
0.4.8
0.4.7
0.4.6
0.4.5
0.4.4
0.4.3
0.4.2
0.4.1
0.4.0
0.3.5
0.3.4
0.3.3
0.3.2
0.3.1
0.3.0
0.2.6
0.2.5
0.2.4
0.2.3
0.2.3-rc.1
0.2.3-rc.0
0.2.2
0.2.1
0.2.0
0.1.14
0.1.13
0.1.12
0.1.11
0.1.9
0.1.8
0.1.7
0.1.6
0.1.5
0.1.4
0.1.3
0.1.2
0.1.1
The extension for integrating Ash resources with Oban.
Current section
Files
Jump to
Current section
Files
lib/verifiers/verify_module_names.ex
defmodule AshOban.Verifiers.VerifyModuleNames do
@moduledoc "Verifies that module names have been set for triggers and scheduled actions"
use Spark.Dsl.Verifier
def verify(dsl_state) do
module = Spark.Dsl.Verifier.get_persisted(dsl_state, :module)
dsl_state
|> AshOban.Info.oban_triggers()
|> Enum.filter(fn trigger ->
trigger.scheduler_cron && !trigger.scheduler_module_name
end)
|> case do
[] ->
:ok
missing ->
IO.warn("""
The following triggers do not have a configured scheduler_module_name.
Each trigger must have a defined module name, otherwise changing
the name of the trigger will lead to "dangling" jobs. See the
`AshOban` documentation for more.
Run `mix ash_oban.set_default_module_names` to fix this automatically.
#{names_list(module, missing)}
""")
end
dsl_state
|> AshOban.Info.oban_triggers()
|> Enum.reject(fn trigger ->
trigger.worker_module_name
end)
|> case do
[] ->
:ok
missing ->
IO.warn("""
The following triggers do not have a configured worker_module_name.
Each trigger must have a defined module name, otherwise changing
the name of the trigger will lead to "dangling" jobs. See the
`AshOban` documentation for more.
Run `mix ash_oban.set_default_module_names` to fix this automatically.
#{names_list(module, missing)}
""")
end
dsl_state
|> AshOban.Info.oban_scheduled_actions()
|> Enum.reject(fn trigger ->
trigger.worker_module_name
end)
|> case do
[] ->
:ok
missing ->
IO.warn("""
The following scheduled actions do not have a configured module_name.
Each scheduled action must have a defined module name, otherwise changing
the name of the trigger will lead to "dangling" jobs. See the
`AshOban` documentation for more.
Run `mix ash_oban.set_default_module_names` to fix this automatically.
#{names_list(module, missing)}
""")
end
end
defp names_list(module, triggers) do
Enum.map_join(triggers, "\n", &"- #{inspect(module)}.#{&1.name}")
end
end