HttpCommandClient

The CommandClient of the peers' HTTP command routes: each command goes, as JSON, to the route its contract gives it (POST /{context}/{aggregate}/{id}/{command}, or without the id for a request that names none: a creation, an unaddressed command, or any command of an aggregate whose id is its owner's, which goes to the caller's own; and for a command whose body names its aggregate, whose body names the request's, as CommandBodies writes it), named by names from its class and the request's type (the one whose contract lists the class when the request leaves it out), on the port transport's mode calls, as caller:

  • in service mode, on the internal port with Wow-Call: the caller's tenant (or the target's of CommandRequest.targetTenant), scope (or CommandRequest.targetScope), operator and application as the root context, a new command id its own root; the peer answers once the command is committed, so send, wait and stream answer that one result, whatever the request's wait plan;

  • in user mode, on the public routes with the forwarded credential: the wait plan as Wow-Wait and its timeout as Wow-Wait-Timeout (send waits for ACCEPTED), the target scope as Wow-Scope, and stream reads the results as server-sent events, one per hop.

Every command carries its request id (Wow-Request-Id, the request's or a new one, kept by every retry) and its expected version (If-Match). A problem the peer answers is a CommandRejectedException when the command was rejected, a me.ahoo.wow.api.problem.WowProblemException otherwise, with the retry of its code; one a retry with the same request id may get past is retried first, as the transport's RetryPolicy says (never a 504). A connection that cannot be made is wow.peer.unavailable once the retries are spent, one lost before the answer wow.command.unknown; a context the endpoints give no URL is an IllegalStateException.

A peer described by its Manifest alone (WowClient.Builder.manifestPeers) takes NamedCommands, named by their type and checked against its Manifest before any request; a command object to it is a configuration error.

Functions

Link copied to clipboard
open override fun of(caller: Caller): CommandClient
Link copied to clipboard
open suspend override fun send(request: CommandRequest<*>): CommandResult
Link copied to clipboard
open override fun stream(request: CommandRequest<*>): Flow<CommandResult>
Link copied to clipboard
open suspend override fun wait(request: CommandRequest<*>): CommandResult