1

Currently I have :inets.start and :ssl.start in the hello/0 function. Is there documentation that discusses pros/cons of putting initialization code in that function vs. elsewhere?

$ cat lib/jsontest.ex
defmodule Jsontest do

  @u1 'https://example.com'
  IO.inspect @u1

  def get(u) do
    IO.puts((to_string Time.utc_now) <> " [get] " <> (to_string u))
    {_, { _, _, body}} = :httpc.request(:get, {u, []}, [], [])
    IO.puts(to_string body)
  end

  def hello do
    :inets.start
    :ssl.start
    get(@u1)
  end

end
AG1
  • 6,648
  • 8
  • 40
  • 57
  • 1
    Is it an application? Do you have a supervision tree? Is this a part of an OTP project? Is it under the umbrella? With the information given this question sounds like “should I have an ice-cream for the dessert or something else?” – Aleksei Matiushkin Apr 30 '19 at 05:00
  • It is a small application. I do not have a supervision tree. It is not part of an OPT project. It is not under the umbrella. – AG1 May 01 '19 at 07:08
  • Then is really does not matter where to put those. Although it makes zero sense to use Elixir outside of OTP. I’d better go with an application, that starts those and has an interface to call `:httpc.request/4`. – Aleksei Matiushkin May 01 '19 at 07:20

0 Answers0