AG1
AG1

Reputation: 6764

elixir: what are pros/cons of putting :inets:start in a function?

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

Upvotes: 1

Views: 139

Answers (0)

Related Questions