ManifestMerger

Assembles a service's Manifest from its modules' fragments. The build merges them into the service's manifest.json; the runtime merges the same fragments when it starts. Both refuse a conflict, so a name the runtime resolves is never ambiguous:

  • a bounded context is declared by one fragment only (and once in it); another fragment may add service routes to it, with the error codes they refuse with, and nothing else (ContextManifest.routes: the server module that holds the handlers adds them to the context its domain module declares);

  • an aggregate type context.aggregate is declared once;

  • a command type, and an event type, context.aggregate.Name is declared once, counting former names (@Alias) as names: an alias without a dot is within its aggregate, one with dots a full type name;

  • a subscription name is declared once within its context;

  • an aggregate's system commands are not names it declares: every aggregate may list the same ones (the lifecycle commands, the snapshot rebuild), and an aggregate keeps them as its one fragment declares them; a domain command never takes a system name, nor a system command a domain one;

  • a schema key of $defs declared by two fragments holds the same schema in both (a type shared by two modules);

  • a route, a method and a path, belongs to one command, one query model or one service route only, an aggregate lists a query model once, a context names a service route once, and no service route takes a reserved segment;

  • a context publishes the state events of one of its own aggregates, each once, and a topic carries one aggregate's state events only, across all contexts;

  • only a saga's subscription handles receipts, of rejections or of commits;

  • no context takes the name of the framework's endpoints, and no command route ends in a segment the framework keeps for itself (CommandRoutes);

  • a context documents an error code once, and not a framework (wow.*) one; a fragment's top-level errors, if any, are the framework's as FrameworkErrors defines them.

Every problem is reported, not just the first. The result lists contexts by name and $defs by key, so the same fragments always give the same Manifest, and carries the framework's error table (FrameworkErrors.ALL).

Functions

Link copied to clipboard
fun merge(fragments: List<ManifestFragment>, service: ServiceInfo? = null): Manifest