ex_nsq v1.1.0 NSQ.Connection

Sets up a TCP connection to NSQD. Both consumers and producers use this.

Link to this section Summary

Types

A tuple with a string ID (used to target the connection in NSQ.Connection.Supervisor) and a PID of the connection

A tuple with a host and a port

A map, but we can be more specific by asserting some entries that should be set for a connection’s state map

Functions

Calls the command and waits for a response. If a command shouldn’t have a response, use cmd_noresponse

Calls the command but doesn’t expect any response. This is important if the NSQ command does not in fact generate a response. If you use cmd and a response is sent, it will live forever in the command queue

Link to this section Types

Link to this type connection()
connection() :: {String.t, pid}

A tuple with a string ID (used to target the connection in NSQ.Connection.Supervisor) and a PID of the connection.

Link to this type host_with_port()
host_with_port() :: {String.t, integer}

A tuple with a host and a port.

Link to this type state()
state() :: %{parent: pid, config: NSQ.Config.t, nsqd: host_with_port}

A map, but we can be more specific by asserting some entries that should be set for a connection’s state map.

Link to this section Functions

Link to this function close(conn, conn_state \\ nil)
close(pid, state) :: any
Link to this function cmd(conn_pid, cmd, timeout \\ 5000)
cmd(pid, tuple, integer) ::
  {:ok, binary} |
  {:error, String.t}

Calls the command and waits for a response. If a command shouldn’t have a response, use cmd_noresponse.

Link to this function cmd_noresponse(conn, cmd)
cmd_noresponse(pid, tuple) ::
  {:ok, reference} |
  {:queued, :nosocket}

Calls the command but doesn’t expect any response. This is important if the NSQ command does not in fact generate a response. If you use cmd and a response is sent, it will live forever in the command queue.

Link to this function get_state(pid)
get_state(pid) :: {:ok, state}
get_state(connection) :: {:ok, state}
Link to this function handle_call(arg1, from, state)
handle_call({:cmd, tuple, atom}, {pid, reference}, state) ::
  {:reply, {:ok, reference}, state} |
  {:reply, {:queued, :nosocket}, state}
handle_call(:stop, {pid, reference}, state) :: {:stop, :normal, state}
handle_call(:state, {pid, reference}, state) :: {:reply, state, state}
handle_call({:nsq_msg, binary}, {pid, reference}, state) :: {:reply, :ok, state}
Link to this function handle_cast(atom, state)
handle_cast(:flush_cmd_queue, state) :: {:noreply, state}
handle_cast(:reconnect, state) :: {:noreply, state}
Link to this function handle_info(arg, state)
handle_info({reference, {:message_done, NSQ.Message.t, any}}, state) :: {:noreply, T.conn_state}
Link to this function init(conn_state)
init(state) :: {:ok, state}
Link to this function start_link(parent, nsqd, config, topic, channel, conn_info_pid, event_manager_pid, opts \\ [])
Link to this function terminate(reason, state)