NSQ.Connection (elixir_nsq v1.2.0)
Sets up a TCP connection to NSQD. Both consumers and producers use this.
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
Returns a specification to start this module under a supervisor.
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.
Callback implementation for GenServer.init/1
.
Types
connection()
A tuple with a string ID (used to target the connection in NSQ.Connection.Supervisor) and a PID of the connection.
host_with_port()
A tuple with a host and a port.
state()
@type 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.
Functions
child_spec(init_arg)
Returns a specification to start this module under a supervisor.
See Supervisor
.
close(conn, conn_state \\ nil)
cmd(conn_pid, cmd, timeout \\ 5000)
Calls the command and waits for a response. If a command shouldn't have a response, use cmd_noresponse.
cmd_noresponse(conn, cmd)
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)
@spec get_state(pid()) :: {:ok, state()}
@spec get_state(connection()) :: {:ok, state()}
init(conn_state)
Callback implementation for GenServer.init/1
.