Skip to content

Features

Tenant aggregate

ITenant / TenantEntity (IAggregateRoot<Guid>, ITenantScopedEntity). Key fields: TenantAggregateId, TenantId, TenantKey, DisplayName, ResidencyRegion, LifecycleStatus, AggregateVersion, CreatedOn, ModifiedOn.

Lifecycle smart enum TenantLifecycleStatusEnumeration: Draft -> Active -> Suspended -> Decommissioned, with AllowedTransitions enforced in DefaultTenantsProcessor.

Domain exceptions: TenantNotFoundException, TenantAlreadyExistsException, TenantStatusTransitionNotAllowedException, TenantOperationPartitionMismatchException, and TenantOperationTenantMismatchException.

Published lifecycle events

Event Topic
TenantCreatedEvent tenants.domain.v1.tenant-created
TenantActivatedEvent tenants.domain.v1.tenant-activated
TenantSuspendedEvent tenants.domain.v1.tenant-suspended
TenantDeletedEvent tenants.domain.v1.tenant-deleted
ResidencyChangedEvent tenants.domain.v1.residency-changed

All implement IEvent, ITenantScopedMessage. Topology in TenantsMassTransitTopology.

Internal saga

TenantLifecycleSaga (FlowModel.MassTransit) consumes the service's own TenantCreatedEvent (correlated by TenantAggregateId, in-memory repository) as an orchestration hook. There are no external cross-context consumers in this repo - Tenants is upstream of the others.

Orleans

TenantLifecycleGrain (ITenantLifecycleGrain : IGrainWithStringKey, keyed by tenant partition id) serializes writes and validates the grain key matches input.TenantId (throws TenantOperationMismatchException).

Metrics

TenantsMetrics - counters/histograms for draft/activate/suspend/decommission/residency commands and the query paths.

See also