Search documentation of macula

# macula_client_behaviour behaviour (macula v0.44.2)

View Source

Behaviour defining the client API contract for Macula connections

This behaviour defines the standard interface that all client implementations must provide, whether connecting via QUIC (macula_client) or local process communication (macula_local_client).

By defining this as a behaviour, we ensure compile-time verification that both implementations maintain API compatibility.

# Summary

## Callbacks

advertise/3
advertise/4
call/3
call/4
connect/2
connect_local/1
disconnect/1
discover_subscribers/2
get_node_id/1
publish/3
publish/4
subscribe/3
unadvertise/2
unsubscribe/2

# Callbacks

# advertise/3

    -callback advertise(Client :: pid(), Procedure :: binary(), Handler :: fun()) ->
                           {ok, reference()} | {error, term()}.

# advertise/4

    -callback advertise(Client :: pid(), Procedure :: binary(), Handler :: fun(), Opts :: map()) ->
                           {ok, reference()} | {error, term()}.

# call/3

    -callback call(Client :: pid(), Procedure :: binary(), Args :: list()) -> {ok, term()} | {error, term()}.

# call/4

    -callback call(Client :: pid(), Procedure :: binary(), Args :: list(), Opts :: map()) ->
                      {ok, term()} | {error, term()}.

# connect/2

    -callback connect(Url :: binary() | string(), Opts :: map()) -> {ok, pid()} | {error, term()}.

# connect_local/1

    -callback connect_local(Opts :: map()) -> {ok, pid()} | {error, term()}.

# disconnect/1

    -callback disconnect(Client :: pid()) -> ok.

# discover_subscribers/2

    -callback discover_subscribers(Client :: pid(), Topic :: binary()) -> {ok, [binary()]} | {error, term()}.

# get_node_id/1

    -callback get_node_id(Client :: pid()) -> {ok, binary()} | {error, term()}.

# publish/3

    -callback publish(Client :: pid(), Topic :: binary(), Payload :: map()) -> ok | {error, term()}.

# publish/4

    -callback publish(Client :: pid(), Topic :: binary(), Payload :: map(), Opts :: map()) ->
                         ok | {error, term()}.

# subscribe/3

    -callback subscribe(Client :: pid(), Topic :: binary(), Handler :: pid() | fun((map()) -> ok)) ->
                           {ok, reference()} | {error, term()}.

# unadvertise/2

    -callback unadvertise(Client :: pid(), Procedure :: binary()) -> ok | {error, term()}.

# unsubscribe/2

    -callback unsubscribe(Client :: pid(), SubRef :: reference()) -> ok | {error, term()}.