/// <inheritdoc/> public async Task <CommittedEvent> CommitEvent( IClientSessionHandle transaction, EventLogSequenceNumber sequenceNumber, DateTimeOffset occurred, Execution.ExecutionContext executionContext, UncommittedEvent @event, CancellationToken cancellationToken) { var eventSource = EventSourceId.NotSet; await InsertEvent( transaction, sequenceNumber, occurred, eventSource, @event, new AggregateMetadata(), executionContext, cancellationToken).ConfigureAwait(false); return(new CommittedEvent( sequenceNumber, occurred, eventSource, executionContext, @event.Type, @event.Public, @event.Content)); }
Task InsertEvent( IClientSessionHandle transaction, EventLogSequenceNumber version, DateTimeOffset occurred, EventSourceId eventSource, UncommittedEvent @event, AggregateMetadata aggregate, Execution.ExecutionContext executionContext, CancellationToken cancellationToken) { return(_streams.DefaultEventLog.InsertOneAsync( transaction, new Event( version, executionContext.ToStoreRepresentation(), new EventMetadata( occurred.UtcDateTime, eventSource, @event.Type.Id, @event.Type.Generation, @event.Public), aggregate, new EventHorizonMetadata(), BsonDocument.Parse(@event.Content)), cancellationToken: cancellationToken)); }
/// <summary> /// Convert <see cref="Execution.ExecutionContext" /> to <see cref="ExecutionContext" />. /// </summary> /// <param name="executionContext"><see cref="Execution.ExecutionContext" />.</param> /// <returns>Converted <see cref="ExecutionContext" />.</returns> public static ExecutionContext ToStoreRepresentation(this Execution.ExecutionContext executionContext) => new ExecutionContext( executionContext.CorrelationId, executionContext.Microservice, executionContext.Tenant, executionContext.Version.ToStoreRepresentation(), executionContext.Environment, executionContext.Claims.ToStoreRepresentation());
public static void ShouldBeTheSameAs(this Execution.ExecutionContext executionContext, ExecutionContext storedExecutionContext) { executionContext.CorrelationId.Value.ShouldEqual(storedExecutionContext.Correlation); executionContext.Environment.Value.ShouldEqual(storedExecutionContext.Environment); executionContext.Microservice.Value.ShouldEqual(storedExecutionContext.Microservice); executionContext.Tenant.Value.ShouldEqual(storedExecutionContext.Tenant); executionContext.Version.ShouldBeTheSameAs(storedExecutionContext.Version); executionContext.Claims.ShouldBeTheSameAs(storedExecutionContext.Claims); }
/// <summary> /// Convert from <see cref="Execution.ExecutionContext"/> to <see cref="grpc.ExecutionContext"/>. /// </summary> /// <param name="executionContext"><see cref="Execution.ExecutionContext"/> to convert from.</param> /// <returns>Converted <see cref="grpc.ExecutionContext"/>.</returns> public static grpc.ExecutionContext ToProtobuf(this Execution.ExecutionContext executionContext) { var protobuf = new grpc.ExecutionContext { Application = Extensions.ToProtobuf(executionContext.Application), BoundedContext = Extensions.ToProtobuf(executionContext.BoundedContext), Tenant = Extensions.ToProtobuf(executionContext.Tenant), CorrelationId = Extensions.ToProtobuf(executionContext.CorrelationId), Environment = executionContext.Environment.Value, Culture = executionContext.Culture?.Name ?? CultureInfo.InvariantCulture.Name }; executionContext.Claims.ToProtobuf().ForEach(protobuf.Claims.Add); return(protobuf); }
/// <inheritdoc/> public async Task <CommittedAggregateEvent> CommitAggregateEvent( IClientSessionHandle transaction, Artifact aggregateRoot, AggregateRootVersion aggregateRootVersion, EventLogSequenceNumber version, DateTimeOffset occurred, EventSourceId eventSource, Execution.ExecutionContext executionContext, UncommittedEvent @event, CancellationToken cancellationToken) { await InsertEvent( transaction, version, occurred, eventSource, @event, new AggregateMetadata { WasAppliedByAggregate = true, TypeId = aggregateRoot.Id, TypeGeneration = aggregateRoot.Generation, Version = aggregateRootVersion }, executionContext, cancellationToken).ConfigureAwait(false); return(new CommittedAggregateEvent( aggregateRoot, aggregateRootVersion, version, occurred, eventSource, executionContext, @event.Type, @event.Public, @event.Content)); }
public override object Execute(object self, Execution.ExecutionContext executionContext) { return(this.Delegate(self, executionContext)); }