Intercluster RPC for Erlang and Elixir.
backwater allows you to call remote modules without depending on the Erlang
distribution protocol. It is targeted at scenarios where nodes in one
datacenter need to call nodes in another, over unsecure or unstable networks.
See the README for an overview, configuration and examples.
References
- Transport options: ranch's
opts,ranch_tcpandranch_ssloption documentation, at https://ninenines.eu/docs/en/ranch/2.1/manual/ - HTTP protocol options: cowboy's
cowboy_httpoption documentation, at https://ninenines.eu/docs/en/cowboy/2.12/manual/cowboy_http/ - hackney request options, at https://github.com/benoitc/hackney
Summary
Functions
Performs a remote call on Endpoint.
Performs a remote call on Endpoint, with Options.
Starts a cleartext cowboy listener that can handle remote calls.
Like start_clear_server/2 but one can specify the listener name and tune
settings.
Starts a TLS cowboy listener that can handle remote calls.
Like start_tls_server/3 but one can specify the listener name and tune
(more) settings.
Stops the cowboy listener under the default name.
Stops the cowboy listener under a specific name.
Types
-type call_opts() :: #{hackney_opts => [hackney_option()], compression_threshold => non_neg_integer(), connect_timeout => timeout(), decode_unsafe_terms => boolean(), max_encoded_result_size => non_neg_integer(), recv_timeout => timeout(), rethrow_remote_exceptions => boolean()}.
-type call_result() :: backwater_response:t(hackney_error()).
-type clear_opts() :: ranch:opts() | ranch_tcp:opts().
-type hackney_error() :: {hackney, term()}.
-type hackney_option() :: proplists:property().
-type http_opts() :: cowboy_http:opts().
-type tls_opts() :: ranch:opts() | ranch_ssl:opts().
Functions
-spec call(Endpoint, Module, Function, Args) -> Result | no_return() when Endpoint :: backwater_request:endpoint(), Module :: module(), Function :: atom(), Args :: [term()], Result :: call_result().
Performs a remote call on Endpoint.
Returns:
{ok, ReturnValue}in case of success{error, term()}otherwise
See also call/5.
-spec call(Endpoint, Module, Function, Args, Options) -> Result | no_return() when Endpoint :: backwater_request:endpoint(), Module :: module(), Function :: atom(), Args :: [term()], Options :: call_opts(), Result :: call_result().
Performs a remote call on Endpoint, with Options.
Returns:
{ok, ReturnValue}in case of success{error, term()}otherwise
See also call/4.
-spec start_clear_server(Secret, ExposedModules) -> {ok, pid()} | {error, term()} when Secret :: binary(), ExposedModules :: [backwater_module_exposure:t()].
Starts a cleartext cowboy listener that can handle remote calls.
Returns:
{ok, ServerPid}in case of success{error, term()}otherwise
See also start_clear_server/4.
-spec start_clear_server(Ref, Secret, ExposedModules, Opts) -> {ok, pid()} | {error, term()} when Ref :: term(), Secret :: binary(), ExposedModules :: [backwater_module_exposure:t()], Opts :: backwater_cowboy_handler:opts(clear_opts() | ranch:opts(), http_opts()).
Like start_clear_server/2 but one can specify the listener name and tune
settings.
Returns:
{ok, ServerPid}in case of success{error, term()}otherwise
See also start_clear_server/2.
-spec start_tls_server(Secret, ExposedModules, TLSOpts) -> {ok, pid()} | {error, term()} when Secret :: binary(), ExposedModules :: [backwater_module_exposure:t()], TLSOpts :: tls_opts() | ranch:opts().
Starts a TLS cowboy listener that can handle remote calls.
Returns:
{ok, ServerPid}in case of success{error, term()}otherwise
See also start_tls_server/4.
-spec start_tls_server(Ref, Secret, ExposedModules, Opts) -> {ok, pid()} | {error, term()} when Ref :: term(), Secret :: binary(), ExposedModules :: [backwater_module_exposure:t()], Opts :: backwater_cowboy_handler:opts(tls_opts() | ranch:opts(), http_opts()).
Like start_tls_server/3 but one can specify the listener name and tune
(more) settings.
Returns:
{ok, ServerPid}in case of success{error, term()}otherwise
See also start_tls_server/3.
-spec stop_server() -> ok | {error, not_found}.
Stops the cowboy listener under the default name.
-spec stop_server(Ref) -> ok | {error, not_found} when Ref :: term().
Stops the cowboy listener under a specific name.