PeerContracts

The peer contracts of a context: what another service needs to know of a context to send it commands, read its published streams and follow a wait chain through it, carried by the jar of the context's api module, so a service that depends on that api knows the context with no configuration.

A contract is a Manifest without a service: the domain module's completed fragment filtered by contractOf (the Gradle plugin's generateWowContract), and the contracts of the api's contexts merged into one by assemble (its assembleWowContract, in the api module). Each jar holds one, at RESOURCE, which a reader finds on a class path with ClassLoader.getResources(RESOURCE), one URL per jar or directory: no directory is listed.

A shaded (uber) jar that merges its libraries' entries into one keeps only one RESOURCE unless it merges the files: one JSON object whose contexts are those of every file and whose $defs and errors are their union. An executable Spring Boot jar keeps each library jar whole and needs nothing.

Properties

Link copied to clipboard
const val RESOURCE: String

Where a jar carries the contract of the contexts of its api module.

Functions

Link copied to clipboard
fun assemble(owner: String, contracts: List<ManifestFragment>, owns: (String) -> Boolean): Manifest?

The contract the api module owner carries: of the contexts of the domain modules' contracts, those whose command and event classes are its own (owns, by binary name). A context with none of its classes is another api module's, and is left out; a context with some of them and not others fails, as does a context two contracts declare. Null when no context is the api module's.

Link copied to clipboard

The binary names of the classes of context's commands and events, the classes its api module holds.

Link copied to clipboard

Every context two of the contracts declare: a context is one api module's.

Link copied to clipboard
fun contractOf(fragments: List<Manifest>, service: String? = null): Manifest

The contract of the contexts of fragments, the completed Manifest fragments of a domain module: per context its name, description, aggregates (state, snapshot, ownership, query models, the commands no edge mounts with their names, aliases, schemas, creation and produced events, and the events), subscriptions (kind, source, function, and the commands they derive, call, handle the rejections of and the commits of: what a wait chain follows), published streams and errors; the framework's errors; and the $defs these refer to, transitively. Routes, schedules, retries and jobs are left out. The service is the one service names, the one that hosts the contexts, which a peer finds by its name: its name alone, none when not given.

Link copied to clipboard

The contracts a node reads on its class path, as the node that serves the contexts served sees them (DX gap G21): each contract without the contexts the node serves, and without the contracts left with none. The node's own api is on its class path, and services that share one class path carry each other's: the node's own class path decides the contexts it serves, never such a contract. Identical copies count once.

Link copied to clipboard
fun packageOf(classes: List<String>): String

The package the binary names classes share: the longest common one, empty when they share none.

Link copied to clipboard
fun viewsOf(context: ContextManifest, defs: Map<String, Any?>): Map<String, String>

The <State>View of each state of context an api module generates, by aggregate name: the binary name <package>.<State>View, its package the one the aggregate's command and event classes share (else the one all the context's classes share), its name the state class's simple name followed by View (its x-wow-class in defs, else its schema key). A state the contract withholds (its stream published without it) has none, nor has a state of no field.

Link copied to clipboard
fun withViews(contract: Manifest): Manifest

contract with each state's StateManifest.view set (viewsOf), as an api module's jar carries it.