Gnat.request

You're seeing just the function request, go back to Gnat module for more information.
Link to this function

request(pid, topic, body, opts \\ [])

View Source

Specs

request(t(), String.t(), binary(), keyword()) ::
  {:ok, message()} | {:error, :timeout}

Send a request and listen for a response synchronously

Following the nats request-response pattern this function generates a one-time topic to receive replies and then sends a message to the provided topic.

Supported options:

  • receive_timeout: an integer number of milliseconds to wait for a response. Defaults to 60_000
  • headers: a set of headers you want to send with the request (see Gnat.pub/4)
{:ok, gnat} = Gnat.start_link()
case Gnat.request(gnat, "i_can_haz_cheezburger", "plZZZZ?!?!?") do
  {:ok, %{body: delicious_cheezburger}} -> :yum
  {:error, :timeout} -> :sad_cat
end