Background
I have a GenServer
that on initialization tries to open an HTTP2 connection and waits for it to be up, using a library called Gun
.
def init(_args), do
{:ok, conn_pid} = Gun.open(@url_domain)
case Gun.await_up(conn_pid) do
{:ok, _protocol} -> IO.puts("Conn up!"); {:ok, conn_pid}
{:error, reason} -> {:stop, reason}
end
end
Problem
Now, this simple code has a problem - it doesn’t compile.
unexpected token: do. In case you wanted to write a “do” expression, you must either use do-blocks or separate the keyword argument with comma. For example, you should either write:
if some_condition? do :this else :that end
or the equivalent construct:
if(some_condition?, do: :this, else: :that)
where “some_condition?” is the first argument and the second argument is a keyword list
May be I am brain dead right now and I don’t know how to make a case
statement, but am I missing something?