Hi. My application uses Horde.DynamicSupervisor
to spawn processing tasks for unique objects. User should be able to abort the task, and for that purpose I am trying to lookup the task in Horde.Registry to then use Horde.DynamicSupervisor.terminate_child(pid)
. However the Registry seems to be unaware of the started task.
Startup
In my application.ex
, I have
children = [
...
{Horde.Registry, [name: DataImportRegistry, keys: :unique, members: :auto]},
{Horde.DynamicSupervisor, [
name: DataImportSupervisor,
strategy: :one_for_one,
restart: :transient,
distribution_strategy: Horde.UniformQuorumDistribution,
max_restarts: 0,
max_seconds: 1,
members: :auto#supervisor_members()
]}
]
opts = [strategy: :one_for_one, name: MyApp.Supervisor]
Supervisor.start_link(children, opts)
Then in the main process:
{:ok, pid} = Horde.DynamicSupervisor.start_child(
DataImportSupervisor,
%{
id: my_data_object.uuid,
start: {Task, :start_link, [DataImportWorker, :process_data_import, [my_data_object, current_user.id, client_ip]]}
})
But when I do Horde.Registry.lookup(DataImportRegistry, my_data_object.uuid)
the output is []
.
So what am I missing? Why is Hordeās DynamicSupervisor not registering the Task in the Registry?
If I do Horde.DynamicSupervisor.which_children(DataImportSupervisor)
the return value is [{:undefined, #PID<0.2240.0>, :worker, [Task]}]
while the task is running. What does :undefined
mean?
Thanks!