ContractDirectory

class ContractDirectory(val local: Manifest, peers: List<ManifestFragment> = emptyList()) : SubscriptionDirectory

The contracts a service knows: its own Manifest, local, and the peer contracts, peers (META-INF/wow/contract.json of each api jar on the class path, which the Gradle plugin packages from the context's domain module; load reads them), without the contexts local serves (PeerContracts.outside, DX gap G21: the service's own api is on its class path, and on a class path that several services share, another service's api carries no contract of this one). It answers, for any context of either:

  • whether a context is the service's own (isLocal), and its contract (contextOf, aggregateOf);

  • the stream a context publishes for an aggregate, with its topic and whether it carries the state (publishedOf);

  • the full type name of a command a Manifest refers to by its schema, #/$defs/<binary name>, and back (commandTypeOf, schemaOf);

  • the contexts the service's sagas call synchronously (contextsCalled);

  • the subscriptions of a context and their kinds (subscriptionOf); as a SubscriptionDirectory, it lets a wait chain name a subscription of another context, and over puts it behind the subscription runtime of the node's own context, which knows its subscriptions' progress.

Startup checks: building it fails with a ContractException listing every problem:

  • the peer contracts conflict (PeerContracts.conflicts): two of them declare one context;

  • a subscription of local reads another context (@OnEvent(aggregates = ["ctx.agg"])) that no Manifest declares, an aggregate the context does not have, or one it does not publish;

  • such a subscription reads events by type that the contract of that aggregate does not declare;

  • such a subscription reads a stream published without the state (includeState = false) but its handler takes a state that is not nullable: its own Manifest source does not say nullableState, which the compiler records for StateEvent<S?> and StateEvent<*>. Each subscription answers for itself: another context's subscription of the same name says nothing of it.

A command a saga refers to (SubscriptionManifest.derives, SubscriptionManifest.rejected) is resolved (commandTypeOf) but not checked here: a lifecycle command is no context's, and whether a chain may follow a saga's hop into a context is the wait's check, from derivedContextsOf.

Constructors

Link copied to clipboard
constructor(local: Manifest, peers: List<ManifestFragment> = emptyList())

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Every context of local and of the peers, in that order.

Link copied to clipboard

The commands of local and the peers by their schemas: :manifest's one naming rule.

Link copied to clipboard

local and the peers, as the fragments wow-client names commands and models by.

Link copied to clipboard
Link copied to clipboard

The names of the contexts local serves.

Link copied to clipboard

The names of the contexts the peers declare.

Link copied to clipboard

The peer contracts given, each without the contexts local serves, and without those left with none.

Functions

Link copied to clipboard

The contract of the aggregate type.

Link copied to clipboard

The aggregate types whose contract, the service's or a peer's, lists a command of the schema schema (#/$defs/<binary name>), a mounted one left out: where a saga sends a command of that class whose ref it leaves out. Empty when none does.

Link copied to clipboard

The commands the subscriptions of local send outside hosted, the contexts a node serves (DX gap G9): for each subscription (context/processor.function), the contexts of the commands its saga derives (SubscriptionManifest.derives), handles the receipts of (SubscriptionManifest.rejected, SubscriptionManifest.committed) or schedules (SubscriptionManifest.schedules) that hosted does not hold. Such a command goes through a command topic. A command referred to by a schema no Manifest decides is another context's too, named UNKNOWN_CONTEXT; a lifecycle command is no context's and is left out.

Link copied to clipboard
fun commandTypeOf(reference: String): String?

The full type name (ctx.agg.Command) of the command reference names: a schema reference (#/$defs/<binary name>) resolves to the command of that schema, in whichever context decides it; a full type name is itself when a context decides it. Null when no context of the service or its peers decides it.

Link copied to clipboard

The contract of context, this service's or a peer's.

Link copied to clipboard

The contexts the saga subscriptions of local call synchronously (SubscriptionManifest.calls), by subscription (context/processor.function): each command's context, or UNKNOWN_CONTEXT for a command no Manifest of the service or its peers decides. Unlike commandsOutside, a called command needs no command topic: the node calls its context's gateway.

Link copied to clipboard
open override fun covers(subscription: String, type: AggregateType): Boolean

Whether subscription of type's context handles the commits of type: the snapshot subscription when type keeps snapshots; another one when it reads its own context and names no aggregates or type's.

Link copied to clipboard
open override fun derivedContextsOf(context: String, subscription: String): Set<String>?

The contexts of the commands the saga subscription of context derives or calls, as its Manifest declares them (SubscriptionManifest.derives and SubscriptionManifest.calls): each command's own context, a schema reference resolved through the Manifest of the context that decides it (commandTypeOf). Null when the subscription declares no derives, or when one of them cannot be resolved: a wait chain after its hop is then not checked.

Link copied to clipboard
open override fun hasContext(context: String): Boolean

Whether a Manifest, the service's own or a peer's, declares context.

Link copied to clipboard
open suspend override fun hasHandled(subscription: String, stream: EventStreamRecord): Boolean

A Manifest says nothing of a subscription's progress (a hop of another context is not checked).

Link copied to clipboard
fun idPropertyOf(commandType: String): String?

The property of the body of a command of commandType (ctx.agg.Command) that holds its aggregate's id, as its context's Manifest names it; null for one whose request names its aggregate.

Link copied to clipboard
fun isLocal(context: String): Boolean

Whether context is one of this service's own.

Link copied to clipboard
open override fun kindOf(context: String, subscription: String): FunctionKind?

The kind of subscription of context, as the context's Manifest lists it, or the built-in snapshot subscription (Hop.SNAPSHOT_SUBSCRIPTION) of a context with an aggregate that keeps snapshots. A saga's @OnRejected handler is not a wait's hop: its rejection ended the wait; an @OnCommitted handler is a saga's hop, which the receipts of the commands it answers signal.

Link copied to clipboard

This directory behind runtime, the subscription directory of the node's ownContext: a hop of it is answered by runtime, which knows the subscriptions the node runs and their progress; a hop of any other context, this service's or a peer's, by the Manifests.

Link copied to clipboard

The stream of type's state events its context publishes, with its topic and includeState; null if none.

Link copied to clipboard
fun schemaOf(commandType: String): String?

The schema reference of the command type commandType (ctx.agg.Command), as its context's Manifest gives it.

Link copied to clipboard

The subscription name (processor.function) of context.