ZenWebsocket.Client.CallFacade (ZenWebsocket v0.8.0)

Copy Markdown View Source

Process-down-safe GenServer.call helpers used by ZenWebsocket.Client.

Touches no Gun state. Every public Client accessor that talks to the connection process goes through safe_call/3.

Summary

Functions

True when a GenServer.call/2 exit means the target process is gone.

GenServer.call/2 that returns fallback when the server process is down.

Starts the Client GenServer, installs the default parent handler when none is provided, and awaits the WebSocket upgrade.

Unwraps a GenServer.call/3 exit into the error reason returned to callers.

Adds a parent-process message handler when :handler is absent from opts.

Functions

process_down_exit?(arg1)

@spec process_down_exit?(term()) :: boolean()

True when a GenServer.call/2 exit means the target process is gone.

safe_call(server_pid, request, fallback)

@spec safe_call(pid(), term(), term()) :: term()

GenServer.call/2 that returns fallback when the server process is down.

start_client(server_module, config, opts, builder)

@spec start_client(module(), ZenWebsocket.Config.t(), keyword(), (map(), pid() ->
                                                              struct())) ::
  {:ok, struct()} | {:error, term()}

Starts the Client GenServer, installs the default parent handler when none is provided, and awaits the WebSocket upgrade.

unwrap_call_exit(reason)

@spec unwrap_call_exit(term()) :: term()

Unwraps a GenServer.call/3 exit into the error reason returned to callers.

with_default_handler(opts, parent_pid)

@spec with_default_handler(
  keyword(),
  pid()
) :: keyword()

Adds a parent-process message handler when :handler is absent from opts.