macula_feeder behaviour (macula v9.3.1)
View SourceBehaviour for supervised content feeders (the put/share side).
put_content/2 is a plain blocking call — no addressable pid to cancel it from outside. This is the provider-side counterpart to macula_download: start_link/4,5 returns immediately with a pid, runs macula:put_content/2 in a linked worker, delivers the outcome to Module:handle_fed/2, and publishes sharing.put_started_v1 / sharing.put_completed_v1 mesh facts around the transfer — including outcome => cancelled if the feeder is stopped before the put 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_feeder).
-behaviour(macula_feeder).
-export([init/1, handle_fed/2]).
init(Parent) -> {ok, Parent}.
handle_fed(Result, Parent) ->
Parent ! {fed, Result},
{stop, normal, Parent}. {ok, Pid} = macula_feeder:start_link(doc_feeder, Pool, Realm,
Bytes, self()).
Summary
Functions
Cancel an in-flight feed. Publishes sharing.put_completed_v1 with outcome => cancelled if the put had not resolved yet.
Start a feeder. Puts Bytes into content storage via Pool.
As start_link/4, with Args passed to Module:init/1.
Callbacks
Functions
-spec cancel(pid()) -> ok.
Cancel an in-flight feed. Publishes sharing.put_completed_v1 with outcome => cancelled if the put had not resolved yet.
-spec start_link(module(), macula:pool(), macula:realm(), binary()) -> {ok, pid()} | {error, term()}.
Start a feeder. Puts Bytes into content storage via Pool.
-spec start_link(module(), macula:pool(), macula:realm(), binary(), term()) -> {ok, pid()} | {error, term()}.
As start_link/4, with Args passed to Module:init/1.