Skip to content

Add domain event publisher to AggregateStore #1098

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop-v1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions Source/EventFlow/Aggregates/AggregateStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public class AggregateStore : IAggregateStore
private readonly ICancellationConfiguration _cancellationConfiguration;
private readonly IAggregateStoreResilienceStrategy _aggregateStoreResilienceStrategy;
private readonly IEventFlowConfiguration _eventFlowConfiguration;
private readonly IDomainEventPublisher _domainEventPublisher;

public AggregateStore(
ILogger<AggregateStore> logger,
Expand All @@ -62,7 +63,8 @@ public AggregateStore(
ITransientFaultHandler<IOptimisticConcurrencyRetryStrategy> transientFaultHandler,
ICancellationConfiguration cancellationConfiguration,
IAggregateStoreResilienceStrategy aggregateStoreResilienceStrategy,
IEventFlowConfiguration eventFlowConfiguration)
IEventFlowConfiguration eventFlowConfiguration,
IDomainEventPublisher domainEventPublisher)
{
_logger = logger;
_serviceProvider = serviceProvider;
Expand All @@ -73,6 +75,7 @@ public AggregateStore(
_cancellationConfiguration = cancellationConfiguration;
_aggregateStoreResilienceStrategy = aggregateStoreResilienceStrategy;
_eventFlowConfiguration = eventFlowConfiguration;
_domainEventPublisher = domainEventPublisher;
}

public async Task<TAggregate> LoadAsync<TAggregate, TIdentity>(
Expand Down Expand Up @@ -206,8 +209,7 @@ await _aggregateStoreResilienceStrategy.BeforeEventPublishAsync<TAggregate, TIde
.ConfigureAwait(false);
try
{
var domainEventPublisher = _serviceProvider.GetRequiredService<IDomainEventPublisher>();
await domainEventPublisher.PublishAsync(
await _domainEventPublisher.PublishAsync(
aggregateUpdateResult.DomainEvents,
cancellationToken)
.ConfigureAwait(false);
Expand Down
7 changes: 2 additions & 5 deletions Source/EventFlow/ValueObjects/SingleValueObjectConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist

return Activator.CreateInstance(objectType, value);
}

public override bool CanConvert(Type objectType)
{
return typeof(ISingleValueObject).GetTypeInfo().IsAssignableFrom(objectType);
}
public override bool CanConvert(Type objectType) => typeof(ISingleValueObject).GetTypeInfo().IsAssignableFrom(objectType);

}
}