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
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.
Link to this section Functions
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.
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.
get_state(pid) :: {:ok, state}
get_state(connection) :: {:ok, 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}
handle_info({reference, {:message_done, NSQ.Message.t, any}}, state) :: {:noreply, T.conn_state}