Search documentation of macula

# macula_relay_client (macula v0.44.2)

View Source

Macula Relay Client — connects to relay servers via QUIC.

Single gen_server managing ONE persistent QUIC connection with automatic failover across multiple relays. On disconnect, cycles to the next relay in the list with exponential backoff + jitter. Replays all subscriptions and procedure registrations on reconnect.

Usage:

       Opts = #{relays => [Relay0, Relay1, Relay2]},
       {ok, Client} = macula_relay_client:start_link(Opts).

Backward compatible with single relay via url key.

# Summary

## Functions

advertise(Pid, Procedure, Handler)
call(Pid, Procedure, Args, Timeout)
handle_call(Request, From, State)
handle_cast(Msg, State)
handle_info(Info, State)
init(Opts)
publish(Pid, Topic, Payload)
start_link(Opts)
stop(Pid)
subscribe(Pid, Topic, Callback)
terminate(Reason, State)
unadvertise(Pid, Procedure)
unsubscribe(Pid, Ref)

# Functions

# advertise(Pid, Procedure, Handler)

    -spec advertise(pid(), binary(), fun((map()) -> {ok, term()} | {error, term()})) -> {ok, reference()}.

# call(Pid, Procedure, Args, Timeout)

    -spec call(pid(), binary(), map(), timeout()) -> {ok, term()} | {error, term()}.

# handle_call(Request, From, State)

# handle_cast(Msg, State)

# handle_info(Info, State)

# init(Opts)

# publish(Pid, Topic, Payload)

    -spec publish(pid(), binary(), binary() | map()) -> ok.

# start_link(Opts)

    -spec start_link(map()) -> {ok, pid()} | {error, term()}.

# stop(Pid)

    -spec stop(pid()) -> ok.

# subscribe(Pid, Topic, Callback)

    -spec subscribe(pid(), binary(), fun((map()) -> ok)) -> {ok, reference()}.

# terminate(Reason, State)

# unadvertise(Pid, Procedure)

    -spec unadvertise(pid(), binary()) -> ok.

# unsubscribe(Pid, Ref)

    -spec unsubscribe(pid(), reference()) -> ok.