backwater (backwater v3.7.0)

Copy Markdown View Source

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

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

call_opts()

-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()}.

call_result()

-type call_result() :: backwater_response:t(hackney_error()).

clear_opts()

-type clear_opts() :: ranch:opts() | ranch_tcp:opts().

hackney_error()

-type hackney_error() :: {hackney, term()}.

hackney_option()

-type hackney_option() :: proplists:property().

http_opts()

-type http_opts() :: cowboy_http:opts().

stack_item()

-type stack_item() ::
          {Module :: module(),
           Function :: atom(),
           Arity :: arity() | (Args :: [term()]),
           Location :: [{file, Filename :: string()} | {line, Line :: pos_integer()}]}.

tls_opts()

-type tls_opts() :: ranch:opts() | ranch_ssl:opts().

Functions

call(Endpoint, Module, Function, Args)

-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.

call(Endpoint, Module, Function, Args, Options)

-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.

start_clear_server(Secret, ExposedModules)

-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.

start_clear_server(Ref, Secret, ExposedModules, Opts)

-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.

start_tls_server(Secret, ExposedModules, TLSOpts)

-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.

start_tls_server(Ref, Secret, ExposedModules, Opts)

-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.

stop_server()

-spec stop_server() -> ok | {error, not_found}.

Stops the cowboy listener under the default name.

stop_server(Ref)

-spec stop_server(Ref) -> ok | {error, not_found} when Ref :: term().

Stops the cowboy listener under a specific name.