IdentityResolver

The one place that decides the tenant, owner, space, aggregate ID and operator of a command or request, from hints tagged with their source. The HTTP adapter, the command factory (in-process CommandGateway callers) and saga-sent commands all resolve through it.

The rule, per fact:

  • The value is the first hint by source precedence: BODY, ROUTE, AUTH, HEADER, UPSTREAM. A caller passes only the hints its entry has, normalized as that entry always has (an HTTP header that is blank is no hint).

  • Since 9.3.0 (V3): for the tenant, owner and space, when the route or the authenticated principal fixes the value, a body or header hint with a different value is rejected with an IllegalArgumentException (IllegalArgument,

  1. instead of silently winning or being ignored. The same value is fine.

Functions

Link copied to clipboard
fun resolve(fact: IdentityFact, vararg hints: IdentityHint?): String?

fun resolve(fact: IdentityFact, firstSource: IdentitySource, first: String?, secondSource: IdentitySource = IdentitySource.UPSTREAM, second: String? = null, thirdSource: IdentitySource = IdentitySource.UPSTREAM, third: String? = null): String?

resolve for up to three hints, each given as its source and value (a null value is no hint), in that order. The same rule without allocating: the per-request paths (HTTP identity, toCommandMessage) use it.

Link copied to clipboard
inline fun resolveAggregateId(ownerIsAggregateId: Boolean, ownerId: String?, aggregateId: String?, generateAggregateId: () -> String): String

The aggregate ID of resolveAggregateIdAndOwner, without the pair.

Link copied to clipboard
fun resolveAggregateIdAndOwner(ownerIsAggregateId: Boolean, ownerId: String?, aggregateId: String?, generateAggregateId: () -> String): Pair<String, String?>

The aggregate ID and owner of a command to an aggregate whose owner may be its ID.

Link copied to clipboard
fun resolveOwnerId(ownerIsAggregateId: Boolean, ownerId: String?, resolvedAggregateId: String): String?

The owner of resolveAggregateIdAndOwner, given the aggregate ID resolveAggregateId returned.