View Source jarl (jarl v1.1.0)
Summary
Functions
Disconnects the client from the JSON-RPC server. The handler will receive a jarl_error message for all pending requests.
Sends a notification to the JSON-RPC server. It may return an error if the connection is not established and the request couldn't be sent.
Sends a result response to a JSON-RPC request. It may return an error if the connection is not established and the response couldn't be sent.
Sends an error response to a JSON-RPC request. It may return an error if the connection is not established and the response couldn't be sent.
Sends a synchronous request to the JSON-RPC server.
Sends an asynchronous request to the JSON-RPC server. The request is sent without waiting for a response. It may return an error if the connection is not established and the request couldn't be sent, but the handler will receive the jarl_error message anyway.
Starts a new JSON-RPC client connection process and links it to the calling process.
Types
-type handler_messages() :: {jarl, pid(), {connected, Headers :: [{binary(), iodata()}]}} | {jarl, pid(), {request, method(), Params :: map() | list(), ReqRef :: binary() | integer()}} | {jarl, pid(), {notification, method(), Params :: map() | list()}} | {jarl, pid(), {result, Result :: term(), Ctx :: term()}} | {jarl, pid(), {error, Code :: integer() | atom(), Message :: undefined | binary(), ErData :: term(), Ctx :: term()}} | {jarl, pid(), {jarl_error, Reason :: jarl_error_reason(), Ctx :: term()}}.
-type jarl_error_reason() :: not_connected | timeout | closed.
-type start_options() :: #{domain := atom() | string() | binary(), port := inet:port_number(), transport := tcp | tls | {tls, TlsOpts :: list()}, path := atom() | string() | binary(), errors => [error_mapping()], ping_timeout => infinity | pos_integer(), request_timeout => infinity | pos_integer(), headers => [{binary(), iodata()}], protocols => [binary()]}.
Functions
-spec disconnect(Conn :: pid()) -> ok.
Disconnects the client from the JSON-RPC server. The handler will receive a jarl_error message for all pending requests.
-spec notify(Conn :: pid(), Method :: method(), Params :: map()) -> ok | {jarl_error, not_connected}.
Sends a notification to the JSON-RPC server. It may return an error if the connection is not established and the request couldn't be sent.
-spec reply(Conn :: pid(), Result :: any(), ReqRef :: binary()) -> ok | {jarl_error, not_connected}.
Sends a result response to a JSON-RPC request. It may return an error if the connection is not established and the response couldn't be sent.
-spec reply(Conn :: pid(), Code :: atom() | integer(), Message :: undefined | binary(), ErData :: term(), ReqRef :: undefined | binary()) -> ok | {jarl_error, not_connected}.
Sends an error response to a JSON-RPC request. It may return an error if the connection is not established and the response couldn't be sent.
-spec request(Conn :: pid(), Method :: method(), Params :: map()) -> {result, Result :: term()} | {error, Code :: integer(), Message :: undefined | binary(), ErData :: term()} | {jarl_error, Reason :: jarl_error_reason()}.
Sends a synchronous request to the JSON-RPC server.
-spec request(Conn :: pid(), Method :: method(), Params :: map(), ReqCtx :: term()) -> ok | {jarl_error, Reason :: jarl_error_reason()}.
Sends an asynchronous request to the JSON-RPC server. The request is sent without waiting for a response. It may return an error if the connection is not established and the request couldn't be sent, but the handler will receive the jarl_error message anyway.
-spec start_link(Handler :: pid(), Options :: start_options()) -> {ok, Conn :: pid()} | {error, Reason :: term()}.
Starts a new JSON-RPC client connection process and links it to the calling process.