In the days of using Supervisor.Spec
to start workers, I could register a process, by name, rather easily:
worker(SolutionDesigner.Repo, [], name: :foo)
In the new idiom of child_spec
the solution I’ve found involves providing an inline child_spec
something like this:
%{
id: SolutionDesigner.Repo,
start: {SolutionDesigner.Repo, :start_link, [[], name: :foo]}
}
Which, in my opinion, is a long row to hoe just to give the process a name. For applications where I control the worker being started I could see moving the naming down into the worker itself - so the worker is in charge of its own name. However, when using workers provided by third-party libraries:
%{
id: Redix,
start: {Redix, :start_link, [[hostname: "localhost", port: 1234], name: :redis]}
}
I find this to be rather inconvenient. Is there a more terse, idiomatic way to name a worker from the start up function for a supervisor.