macula_feeder behaviour (macula v9.8.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).
Direct-dial
start_link/4,5 puts through the pool's own connected link (whichever pick_connected_link/1 picks). start_link_direct/4,5 is the direct-dial counterpart: unlike macula_download's (which resolves an MCID to find out WHO has it), a PUT already knows its own target — the caller names Station directly, and it is resolved to a dialable endpoint via that station's own signed station_endpoint record and dialed in one hop, deliberately seeding that specific station instead of whichever the pool picks. See macula_direct_dial's module doc, "Content" section, for the trust model.
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.
As start_link/4, but resolves Station's own station_endpoint and dials it directly instead of putting through the pool's existing links. See the "Direct-dial" section above.
As start_link_direct/5, 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.
-spec start_link_direct(module(), macula:pool(), macula_identity:pubkey(), macula:realm(), binary()) -> {ok, pid()} | {error, term()}.
As start_link/4, but resolves Station's own station_endpoint and dials it directly instead of putting through the pool's existing links. See the "Direct-dial" section above.
-spec start_link_direct(module(), macula:pool(), macula_identity:pubkey(), macula:realm(), binary(), term()) -> {ok, pid()} | {error, term()}.
As start_link_direct/5, with Args passed to Module:init/1.