Search documentation of macula

# macula_advertisement_manager (macula v0.44.2)

View Source

Advertisement manager GenServer - manages DHT service advertisements.

Responsibilities: - Advertise services in DHT with periodic re-advertisement - Unadvertise services and cancel timers - Register handlers with local gateway - Manage service advertisement lifecycle - Periodic cleanup of expired local services (every 60s, TTL 300s default)

Extracted from macula_connection.erl (Phase 6)

# Summary

## Functions

advertise_service(Pid, Procedure, Handler, Opts)

Advertise a service in DHT and local registry

get_active_advertisements(Pid)

Get list of actively advertised services

handle_call(Request, From, State)
handle_cast(Msg, State)
handle_info(Info, State)

Handle re-advertisement timer

init(Opts)
start_link(Opts)
terminate(Reason, State)
unadvertise_service(Pid, Procedure)

Stop advertising a service

# Functions

# advertise_service(Pid, Procedure, Handler, Opts)

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

Advertise a service in DHT and local registry

# get_active_advertisements(Pid)

    -spec get_active_advertisements(pid()) -> {ok, [binary()]}.

Get list of actively advertised services

# handle_call(Request, From, State)

# handle_cast(Msg, State)

# handle_info(Info, State)

Handle re-advertisement timer

# init(Opts)

# start_link(Opts)

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

# terminate(Reason, State)

# unadvertise_service(Pid, Procedure)

    -spec unadvertise_service(pid(), binary() | atom() | string()) -> ok | {error, term()}.

Stop advertising a service