macula_group_opener (macula v13.4.0)

View Source

The process that opens a sealed group's events for one subscription (plans/DESIGN_E2E_SEALED_PUBSUB.md §6, §7).

The pool hands it every event the subscription's ordering releases, in order, and it answers the subscriber:

  • a sealed event under an epoch the keyring holds, or pulls by id, and that opens: {macula_event, SubRef, Topic, Payload, Meta} with sealed => 1 and seal_key_id in the meta;
  • a sealed event that cannot be opened: {macula_event_unopened, SubRef, Topic, #{publisher, seal_key_id, reason}} once, and nothing of the payload. reason is unknown_epoch, epoch_expired, not_a_member, membership_unknown, no_distributor, no_group (the group was left) or tag_invalid;
  • a clear event: delivered with sealed => 0, unless this node holds required for a prefix covering its topic, when it is refused, counted and logged naming its publisher.

It runs apart from the pool because opening may pull a missed epoch from the distributor, over the pool, for as long as that call's deadline: the pool never waits on it. It ends when the pool does, or when told to stop.

Summary

Functions

A clear event, as every subscription on this node takes it: handed to Deliver with sealed => 0, unless the node holds required for a prefix covering Topic, when it is refused, counted and logged naming its publisher. Reads the keyring's table only, so the pool calls it too.

Hand the opener one event the subscription's ordering released.

Start an opener; the caller monitors it.

Types

options/0

-type options() ::
          #{keyring := macula_group_keyring:keyring(),
            subscriber := pid(),
            sub_ref := reference(),
            realm := <<_:256>>,
            prefix := binary(),
            pool := pid()}.

Functions

delivered(Keyring, Topic, Meta, Deliver)

-spec delivered(macula_group_keyring:keyring(), binary(), map(), fun((map()) -> term())) -> ok.

A clear event, as every subscription on this node takes it: handed to Deliver with sealed => 0, unless the node holds required for a prefix covering Topic, when it is refused, counted and logged naming its publisher. Reads the keyring's table only, so the pool calls it too.

open(Opener, Topic, Payload, Meta)

-spec open(pid(), binary(), term(), map()) -> ok.

Hand the opener one event the subscription's ordering released.

start(Opts)

-spec start(options()) -> pid().

Start an opener; the caller monitors it.

stop(Opener)

-spec stop(pid()) -> ok.