View Source ExRocketmq.Transport.Tcp (lib_oss v0.1.0)
Implement the transport layer of the rocketmq protocol via tcp
Summary
Functions
return infomaion of the transport
create new instance of the tcp transport
output a binary data through the transport socket
recv a binary packet from the transport socket
start
starts Genserver of the transport and set the pid
field of the transport
Types
@type t() :: %ExRocketmq.Transport.Tcp{ host: String.t(), opts: ExRocketmq.Typespecs.opts(), pid: pid(), port: non_neg_integer(), sockopts: ExRocketmq.Typespecs.opts(), timeout: non_neg_integer() }
The type of the transport
- pid: the pid of the transport, the
start
function will set this field; - host: the host of the target server;
- port: the port of the target server;
- timeout: connection timeout in milliseconds;
- sockopts: the socket options of gen_tcp;
- opts: the other options of the transport;
Functions
return infomaion of the transport
Examples
iex> info(transport)
{:ok, %{pid: pid, host: host, port: port}}
@spec new(tcp_opts_schema_t()) :: t()
create new instance of the tcp transport
Options
:host
(String.t/0
) - Required. The host of the nameserver:port
(integer/0
) - Required. The port of the nameserver:timeout
(integer/0
) - The timeout of the transport The default value is5000
.:sockopts
(list ofterm/0
) - The socket options of the transport The default value is[]
.:opts
(keyword/0
) - The other options of the transport The default value is[]
.
Examples
iex> new(host: "some host", port: 1234)
%ExRocketmq.Transport.Tcp{
pid: nil,
host: "some host",
port: 1234,
timeout: 5000,
sockopts: [],
opts: []
}
output a binary data through the transport socket
Examples
iex> output(transport, "some data")
:ok
recv a binary packet from the transport socket
Examples
iex> recv(transport)
{:ok, "some data"}
start
starts Genserver of the transport and set the pid
field of the transport