warning: Supervisor.Spec.supervisor/2 is deprecated. Use the new child specifications outlined in the Supervisor module instead
Found at 2 locations:
lib/my_app123/application.ex:9: MyApp123.Application.start/2
lib/my_app123/application.ex:10: MyApp123.Application.start/2
warning: Supervisor.Spec.worker/2 is deprecated. Use the new child specifications outlined in the Supervisor module instead
Found at 3 locations:
lib/my_app123/application.ex:11: MyApp123.Application.start/2
lib/my_app123/application.ex:12: MyApp123.Application.start/2
lib/my_app123/application.ex:13: MyApp123.Application.start/2
I wasnāt trying to be unhelpful, sorry. You said you checked the Spec docs, which only state that itās deprecated and not how to change it, so that wouldnāt be the right place to look. I therefore provided you with an example of the new way. My thinking was along the lines āreplicate the example and change it to fit your purposeā, but @LostKobrakaiās link is probably more useful
@ojinari when people are trying to help you and youāre not quite sure how their post aims to, it might be better to ask for clarification (such as, āWhich part of the docs are you referring to specifically?ā) rather than telling them they are being āunusefulā or unhelpful. Generally people will be more inclined to help if they feel you appreciate the time and effort they are putting in to your thread to help you
FWIW, this is going to have a slightly different effect than the old supervisor function - that sets shutdown to :infinity because supervisors are responsible for waiting for all of their children to shut down.
You could address this in several ways, based on the docs:
set shutdown: :infinity in the specs to match the behavior of the deprecated supervisor function exactly
set type: :supervisor in the specs, which ensures that shutdown defaults to the right value
I understood the difference, of using the shutdown: and type:. But when I tried to use the shorthand version in my primer supervisor. The code breaks and returns.
function ElhexDelivery.PostalCode.Supervisor.start_link/1 is undefined or private
By the doc should work, but I didnāt understand what I have to change in this call to make that keep working.
The child_spec function generated by use Supervisor expects a single argument thatās forwarded along to the moduleās start_link/1 function - your ElhexDelivery.PostalCode.Supervisor only defines a start_link/0 so you get the āundefined or privateā error.
I think in most cases @al2o3cr 's suggestion of using the default generated child_spec/1 and start_link/1 functions are not only less code to write, but also less error prone and more idiomatic in Elixir. Even if you do have to customize your child spec there are other ways to go about it than writing the map out by hand.