PeerEvents

class PeerEvents(contexts: List<ContextManifest>, classLoader: ClassLoader = PeerEvents::class.java.classLoader)

The events of the contexts a service knows, decoded into their api classes: an event of a published stream, context.aggregate.Event, is decoded into the class its context's contract names for it (#/$defs/<binary name>) when that class is on classLoader and the event is of the revision the contract declares; otherwise it is a PublishedEvent of its name, revision and JSON text. A matched class that does not decode the payload fails the handling, as a state that does not decode does.

Each aggregate's events are known by every name a record of that aggregate's stream may carry them under (namesOf): an event's name and its former ones (@Alias), since a topic keeps the records published under a former name, those before the rename and those a node of the producer's earlier code publishes until it is upgraded (#7567). A former name, simple or full, is a name of its own aggregate's stream alone, as the producer's kernel reads it: the same full name on two aggregates' streams is each aggregate's own event. A record under a former name is decoded into the renamed event's class at the contract's revision alone, as one under the current name is; any other revision, or a class not on classLoader, stays a PublishedEvent of the name and revision it was published under.

Two events of one aggregate that claim one name are refused when it is built (conflictsOf), so a name of a stream is one event's; ContractDirectory refuses the same, naming the contract, where the contracts are read.

Constructors

Link copied to clipboard
constructor(contexts: List<ContextManifest>, classLoader: ClassLoader = PeerEvents::class.java.classLoader)

Types

Link copied to clipboard

Functions

Link copied to clipboard
fun decode(type: AggregateType, events: List<Any>, codec: EventCodec): List<Any>

events, a published stream's of the aggregate type, each decoded into its api class or kept as a PublishedEvent.

Link copied to clipboard
fun requireRevisions(aggregate: AggregateType, events: List<StateEventPayload>, type: Class<*>?)

Refuses events, a published stream's of the aggregate aggregate, when one of them is an event a handler of type takes, at a revision its contract does not declare (#7604): the handling fails, so the subscription retries and parks the aggregate, as the service's own subscriptions do for a revision their model cannot read, rather than passing the commit over as if it held another event. It is asked once a commit, before any call, so a commit is handled whole or not at all. A handler of no type, the whole stream's, takes every revision, as a PublishedEvent.