macula_content_transfer_registry (macula v10.1.1)

View Source

Correlation-id registry for macula_content_transfer handles.

Each transfer mints a share_id (already published in sharing.put_started_v1 / sharing.get_started_v1 etc. by macula_feeder / macula_download). A caller that only saw the id in a published mesh fact — not the pid — needs a way to reach cancel/1,3; this table is that lookup. Monitor-based cleanup: an entry disappears the instant its owning process exits, no caller needs to unregister explicitly.

Table is protected — any process can read it directly via ets:lookup/2 (see whereis_share/1), only this gen_server ever writes to it.

Summary

Functions

Register Pid under ShareId. Overwrites any prior owner for the same id (last writer wins — ids are crypto:strong_rand_bytes/1 output, a collision here means a caller deliberately reused one).

Start the registry. One per node, under macula_root.

Look up the pid owning ShareId, if it's still alive.

Functions

register_share(ShareId, Pid)

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

Register Pid under ShareId. Overwrites any prior owner for the same id (last writer wins — ids are crypto:strong_rand_bytes/1 output, a collision here means a caller deliberately reused one).

start_link()

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

Start the registry. One per node, under macula_root.

whereis_share(ShareId)

-spec whereis_share(binary()) -> {ok, pid()} | {error, not_found}.

Look up the pid owning ShareId, if it's still alive.