fed-sx-m2: Step 8d — outbox dispatches delivery_set to workers + 7 tests
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 32s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 32s
outbox:publish/2 now walks the computed delivery_set and enqueues
the signed activity onto each matching delivery_worker
(registered under the peer-id atom). Missing workers are silently
skipped — lazy worker creation belongs to the kernel manager
later in Step 8.
Gated by Context's {dispatch_deliveries, true} so every M1
outbox caller (and every M2 caller that doesn't yet care about
delivery) stays back-compat: default off.
New helpers in outbox.erl:
dispatch_deliveries/3(Activity, DeliverySet, Context)
gates on Context :dispatch_deliveries flag
enqueue_each/2(Activity, [PeerId | _])
whereis-guarded enqueue per peer
7/7 in next/tests/delivery_dispatch.sh:
- single peer enqueued
- two peers both enqueued (fan-out)
- missing worker silently skipped
- no :dispatch_deliveries flag -> no-op (back-compat)
- two publishes -> FIFO append on the queue
- empty delivery_set -> no-op
outbox_publish.sh 17/17 unchanged; delivery_worker.sh 17/17
unchanged. Conformance preserved at 761/761 from the Step 8a
baseline.
This commit is contained in:
@@ -93,6 +93,7 @@ publish(Request, Context) ->
|
||||
{ok, NewLog, _Seq} = log:append(LogState, Signed),
|
||||
broadcast(Signed, envelope_field(projections, Context)),
|
||||
DeliverySet = compute_delivery_set(Request, Signed, Context),
|
||||
dispatch_deliveries(Signed, DeliverySet, Context),
|
||||
Result = [{cid, cid_of(Signed)},
|
||||
{activity, Signed},
|
||||
{delivery_set, DeliverySet}],
|
||||
@@ -101,6 +102,37 @@ publish(Request, Context) ->
|
||||
{error, Reason, LogState}
|
||||
end.
|
||||
|
||||
%% dispatch_deliveries/3 — Step 8d. For each ActorId in the
|
||||
%% delivery_set, enqueue the signed activity onto the matching
|
||||
%% delivery_worker if the worker is registered under that atom.
|
||||
%% Missing workers are silently skipped — lazy creation belongs
|
||||
%% to the kernel manager (later in Step 8). The Context
|
||||
%% `:dispatch_deliveries` field gates the call so existing
|
||||
%% outbox callers that don't yet care about delivery (e.g. all of
|
||||
%% M1's tests) stay back-compat.
|
||||
%%
|
||||
%% No-op when:
|
||||
%% - :dispatch_deliveries is absent or not the atom true
|
||||
%% - delivery_set is []
|
||||
%% - the per-peer worker isn't registered (whereis returns undefined)
|
||||
|
||||
dispatch_deliveries(Activity, DeliverySet, Context) ->
|
||||
case envelope_field(dispatch_deliveries, Context) of
|
||||
true -> enqueue_each(Activity, DeliverySet);
|
||||
_ -> ok
|
||||
end.
|
||||
|
||||
enqueue_each(_Activity, []) -> ok;
|
||||
enqueue_each(Activity, [PeerId | Rest]) when is_atom(PeerId) ->
|
||||
case erlang:whereis(PeerId) of
|
||||
undefined -> enqueue_each(Activity, Rest);
|
||||
_ ->
|
||||
delivery_worker:enqueue(PeerId, Activity),
|
||||
enqueue_each(Activity, Rest)
|
||||
end;
|
||||
enqueue_each(Activity, [_ | Rest]) ->
|
||||
enqueue_each(Activity, Rest).
|
||||
|
||||
%% compute_delivery_set/3 — Step 7c. Pulls the audience-resolved
|
||||
%% recipient list off the Request's `:to` / `:cc` fields (the
|
||||
%% envelope itself doesn't carry them — construct/4 only takes
|
||||
|
||||
Reference in New Issue
Block a user