macula_download behaviour (macula v9.3.0)
View SourceBehaviour for supervised content downloads (the get/fetch side).
get_content/2 is a plain blocking call — no addressable pid to cancel it from outside. This is the consumer-side counterpart to macula_feeder: start_link/4,5 returns immediately with a pid, runs macula:get_content/2 in a linked worker, delivers the outcome to Module:handle_downloaded/2, and publishes sharing.get_started_v1 / sharing.get_completed_v1 mesh facts around the transfer — including outcome => cancelled if the download is cancelled before the get resolves.
This is content sharing, not general-purpose RPC streaming — see macula_streamer / macula_stream_sink for that (streaming.* facts belong to that pair).
Example
-module(doc_download).
-behaviour(macula_download).
-export([init/1, handle_downloaded/2]).
init(Parent) -> {ok, Parent}.
handle_downloaded(Result, Parent) ->
Parent ! {downloaded, Result},
{stop, normal, Parent}. {ok, Pid} = macula_download:start_link(doc_download, Pool, Realm,
Mcid, self()).
Summary
Functions
Cancel an in-flight download. Publishes sharing.get_completed_v1 with outcome => cancelled if the get had not resolved yet.
Start a download. Fetches Mcid via Pool.
As start_link/4, with Args passed to Module:init/1.
Callbacks
Functions
-spec cancel(pid()) -> ok.
Cancel an in-flight download. Publishes sharing.get_completed_v1 with outcome => cancelled if the get had not resolved yet.
-spec start_link(module(), macula:pool(), macula:realm(), macula:mcid()) -> {ok, pid()} | {error, term()}.
Start a download. Fetches Mcid via Pool.
-spec start_link(module(), macula:pool(), macula:realm(), macula:mcid(), term()) -> {ok, pid()} | {error, term()}.
As start_link/4, with Args passed to Module:init/1.