JSONRPC2 v1.2.0 JSONRPC2.Clients.TCP View Source
A client for JSON-RPC 2.0 using a line-based TCP transport.
Link to this section Summary
Functions
Call the given method
with params
using the client pool named name
with options
.
Asynchronously call the given method
with params
using the client pool named name
with
options
.
Send a notification with the given method
and params
using the client pool named name
.
Receive the response for a previous cast/3
which returned a request_id
.
Start a client pool named name
, connected to host
at port
.
Stop the client pool with name name
.
Link to this section Types
call_option()
View Source
call_option() :: {:string_id, boolean()} | {:timeout, pos_integer()}
call_option() :: {:string_id, boolean()} | {:timeout, pos_integer()}
call_options()
View Source
call_options() :: [call_option()]
call_options() :: [call_option()]
cast_options()
View Source
cast_options() :: [{:string_id, boolean()}]
cast_options() :: [{:string_id, boolean()}]
host()
View Source
host() :: binary() | :inet.socket_address() | :inet.hostname()
host() :: binary() | :inet.socket_address() | :inet.hostname()
request_id()
View Source
request_id() :: any()
request_id() :: any()
Link to this section Functions
call(name, method, params, options \\ [])
View Source
call(atom(), JSONRPC2.method(), JSONRPC2.params(), boolean() | call_options()) ::
{:ok, any()} | {:error, any()}
call(atom(), JSONRPC2.method(), JSONRPC2.params(), boolean() | call_options()) :: {:ok, any()} | {:error, any()}
Call the given method
with params
using the client pool named name
with options
.
You can provide the option string_id: true
for compatibility with pathological implementations,
to force the request ID to be a string.
You can also provide the option timeout: 5_000
to set the timeout to 5000ms, for instance.
For backwards compatibility reasons, you may also provide a boolean for the options
parameter,
which will set string_id
to the given boolean.
cast(name, method, params, options \\ [])
View Source
cast(atom(), JSONRPC2.method(), JSONRPC2.params(), boolean() | cast_options()) ::
{:ok, request_id()} | {:error, :backlog_full}
cast(atom(), JSONRPC2.method(), JSONRPC2.params(), boolean() | cast_options()) :: {:ok, request_id()} | {:error, :backlog_full}
Asynchronously call the given method
with params
using the client pool named name
with
options
.
Use receive_response/1
with the request_id
to get the response.
You can provide the option string_id: true
for compatibility with pathological implementations,
to force the request ID to be a string.
You can also provide the option timeout: 5_000
to set the timeout to 5000ms, for instance.
Additionally, you may provide the option pid: self()
in order to specify which process should
be sent the message which is returned by receive_response/1
.
For backwards compatibility reasons, you may also provide a boolean for the options
parameter,
which will set string_id
to the given boolean.
notify(name, method, params)
View Source
notify(atom(), JSONRPC2.method(), JSONRPC2.params()) ::
{:ok, request_id()} | {:error, :backlog_full}
notify(atom(), JSONRPC2.method(), JSONRPC2.params()) :: {:ok, request_id()} | {:error, :backlog_full}
Send a notification with the given method
and params
using the client pool named name
.
This function returns a request_id
, but it should not be used with receive_response/1
.
receive_response(request_id)
View Source
receive_response(request_id()) :: {:ok, any()} | {:error, any()}
receive_response(request_id()) :: {:ok, any()} | {:error, any()}
Receive the response for a previous cast/3
which returned a request_id
.
start(host, port, name, client_opts \\ [], pool_opts \\ [])
View Source
start(host(), :inet.port_number(), atom(), Keyword.t(), Keyword.t()) :: :ok
start(host(), :inet.port_number(), atom(), Keyword.t(), Keyword.t()) :: :ok
Start a client pool named name
, connected to host
at port
.
You can optionally pass client_opts
, detailed
here, as well as pool_opts
, detailed
here.
stop(name)
View Source
stop(atom()) :: :ok | {:error, :shackle_not_started | :pool_not_started}
stop(atom()) :: :ok | {:error, :shackle_not_started | :pool_not_started}
Stop the client pool with name name
.