macula_provider_authority_follower (macula v17.1.1)
View SourceA caller's stream holds no longer than its provider's authorization (macula#120).
A stream opened against a provider's verified advertisement of an org procedure was opened under that provider's authorization: the realm-signed org directory and the org-signed procedure delegation, which end at macula_record:authorization_ends_at/3. A provider the org stops delegating to, or the realm stops listing, is not renewed, so its authorization ends and the stream with it. A provider in good standing renews its chain before then (D32), so the follower looks for that renewal at a third of the time left: the ends of the provider's renewed advertisements, verified and trusted as at the open, and moves the stream's end to the latest of them. Only a later end moves it. A lookup that finds nothing, only earlier ends, or fails, leaves the end where it is: a withheld renewal can only let the stream reach its end, never keep it open past it. At the end the stream is aborted unauthorized. The follower watches the stream and ends with it.
Given a standing reader, the follower also re-reads the provider's delegation slot every re-check (60 s by default, the standing_recheck_ms application env): the org's tombstone of the delegation, {error, withdrawn}, aborts the stream at once. Any other answer, a failed lookup or a reader that raises included, is no evidence of revocation and leaves the stream to its end.
Summary
Functions
follow/4 without a standing re-check.
Follow Stream until EndsAt (milliseconds), moving the end to the latest of the ends Renewed(Deadline) answers, by Deadline (milliseconds), when it is later. With a standing reader, read it every recheck_ms and abort the stream when it answers {error, withdrawn}. Returns the follower's pid.
Types
-type opts() :: #{standing => standing(), recheck_ms => pos_integer()}.
-type standing() :: fun(() -> ok | {error, term()}).
Functions
follow/4 without a standing re-check.
Follow Stream until EndsAt (milliseconds), moving the end to the latest of the ends Renewed(Deadline) answers, by Deadline (milliseconds), when it is later. With a standing reader, read it every recheck_ms and abort the stream when it answers {error, withdrawn}. Returns the follower's pid.