Search documentation of macula

# macula_pubsub_handler (macula v0.44.2)

View Source

PubSub handler GenServer - facade that orchestrates pub/sub operations.

This module acts as a facade/coordinator, delegating business logic to: - macula_pubsub_subscription: Subscription storage, pattern matching, callbacks - macula_pubsub_dht: DHT advertisement, discovery, routing - macula_pubsub_qos: QoS 1 tracking and retry logic

Responsibilities: - API facade for subscribe/unsubscribe/publish operations - Message routing coordination between specialized modules - GenServer lifecycle management - State management (delegates actual operations to modules)

Extracted from macula_connection.erl (Phase 4) Refactored using TDD to extract god module (Phase 5)

# Summary

## Functions

handle_call(Request, From, State)
handle_cast(Msg, State)
handle_incoming_publish(Pid, Msg)
handle_info(Info, State)
init(Opts)
publish(Pid, Topic, Data, Opts)
start_link(Opts)
subscribe(Pid, Topic, Callback)
terminate(Reason, State)
unsubscribe(Pid, SubRef)

# Functions

# handle_call(Request, From, State)

# handle_cast(Msg, State)

# handle_incoming_publish(Pid, Msg)

    -spec handle_incoming_publish(pid(), map()) -> ok.

# handle_info(Info, State)

# init(Opts)

# publish(Pid, Topic, Data, Opts)

    -spec publish(pid(), binary() | list() | atom(), term(), map()) -> ok | {error, term()}.

# start_link(Opts)

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

# subscribe(Pid, Topic, Callback)

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

# terminate(Reason, State)

# unsubscribe(Pid, SubRef)

    -spec unsubscribe(pid(), reference()) -> ok | {error, term()}.