CommandRequest

class CommandRequest<C : Any> @InternalWowApi constructor(val command: C, val id: String? = null, val type: AggregateType? = null, val targetTenant: String? = null, val targetScope: Scope? = null, val wait: WaitPlan? = null, val timeout: Duration? = null, val requestId: String? = null, val expectedVersion: Int? = null)

One command a CommandClient sends, and how: the command object, the aggregate it goes to, the scope it acts in and what the sender waits for.

  • command: the command object, sent as it is (not a Command, whose identity the client gives it).

  • id: the aggregate's id; null when the command names no aggregate id: a creation, whose id the server assigns, or an @Unaddressed command, whose transformer finds its aggregate. The command's model on the server decides which, never the client.

  • type: the aggregate type; null to derive it from the command's class, from the models of the service's own contexts and the contracts of its peers. A class no aggregate known to the client decides, or several decide, fails when it is sent, as does a lifecycle command (DeleteAggregate, ...), which every aggregate takes: CommandRequest.of(DeleteAggregate, id, type = ShopContract.Cart.TYPE).

  • targetTenant and targetScope: the tenant and scope a cross-scope caller acts in (Wow-Scope); the caller's own when unset. They are the only source of the tenant and scope: a target tenant that is the caller's own changes nothing.

  • wait (Wow-Wait; the server's default plan when null) within timeout when given (Wow-Wait-Timeout).

  • requestId, which makes the command idempotent (Wow-Request-Id). When null, each send takes a new one, which the client's own retries keep; a request sent again by the application is then another request. For an application-level retry, set requestId (or keep the one the first result reports) and send that request again.

  • expectedVersion of the aggregate (If-Match; 0 for one never written).

Build it with of, builder or to; the constructor is internal to Wow. Fields may be added.

Constructors

Link copied to clipboard
constructor(command: C, id: String? = null, type: AggregateType? = null, targetTenant: String? = null, targetScope: Scope? = null, wait: WaitPlan? = null, timeout: Duration? = null, requestId: String? = null, expectedVersion: Int? = null)

Types

Link copied to clipboard
class Builder<C : Any>

Builds a CommandRequest, one setter per field; build checks it as the constructor does.

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
val command: C
Link copied to clipboard
Link copied to clipboard
val id: String?
Link copied to clipboard

The plan the command waits with: wait (or the default plan when only a timeout is given) within timeout.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard

A builder of this request, to change some of its fields: the others, requestId included, are kept.

Link copied to clipboard
open override fun toString(): String