Skip to content

Commit

Permalink
Merge pull request #899 from eventflow/fix-missing-id-in-log
Browse files Browse the repository at this point in the history
Fix missing id in log
  • Loading branch information
rasmus authored Sep 9, 2021
2 parents b03967c + f866bc8 commit d93b883
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
21 changes: 13 additions & 8 deletions Source/EventFlow/EventFlowOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using EventFlow.Aggregates;
using EventFlow.Commands;
Expand Down Expand Up @@ -53,11 +53,11 @@ namespace EventFlow
{
public class EventFlowOptions : IEventFlowOptions
{
private readonly List<Type> _aggregateEventTypes = new List<Type>();
private readonly List<Type> _sagaTypes = new List<Type>();
private readonly List<Type> _commandTypes = new List<Type>();
private readonly ConcurrentBag<Type> _aggregateEventTypes = new ConcurrentBag<Type>();
private readonly ConcurrentBag<Type> _sagaTypes = new ConcurrentBag<Type>();
private readonly ConcurrentBag<Type> _commandTypes = new ConcurrentBag<Type>();
private readonly EventFlowConfiguration _eventFlowConfiguration = new EventFlowConfiguration();
private readonly List<Type> _jobTypes = new List<Type>
private readonly ConcurrentBag<Type> _jobTypes = new ConcurrentBag<Type>
{
typeof(PublishCommandJob),
typeof(DispatchToAsynchronousEventSubscribersJob)
Expand All @@ -73,8 +73,13 @@ private EventFlowOptions(IServiceCollection serviceCollection)
RegisterDefaults(ServiceCollection);
}

public static IEventFlowOptions New() => new EventFlowOptions(new ServiceCollection()
.AddLogging(b => b.AddConsole()));
public static IEventFlowOptions New() =>
new EventFlowOptions(
new ServiceCollection()
.AddLogging(b => b
.SetMinimumLevel(LogLevel.Trace)
.AddConsole()));

public static IEventFlowOptions New(IServiceCollection serviceCollection) => new EventFlowOptions(serviceCollection);

public IEventFlowOptions ConfigureOptimisticConcurrencyRetry(int retries, TimeSpan delayBeforeRetry)
Expand Down Expand Up @@ -212,7 +217,7 @@ private void RegisterDefaults(IServiceCollection serviceCollection)
serviceCollection.TryAddSingleton<ISagaDefinitionService, SagaDefinitionService>();
serviceCollection.TryAddSingleton<ICommandDefinitionService, CommandDefinitionService>();

serviceCollection.AddSingleton<ILoadedVersionedTypes>(r => new LoadedVersionedTypes(
serviceCollection.TryAddSingleton<ILoadedVersionedTypes>(r => new LoadedVersionedTypes(
_jobTypes,
_commandTypes,
_aggregateEventTypes,
Expand Down
1 change: 1 addition & 0 deletions Source/EventFlow/IEventFlowOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public interface IEventFlowOptions
{
IServiceCollection ServiceCollection { get; }

IEventFlowOptions ConfigureThrowSubscriberExceptions(bool shouldThrow);
IEventFlowOptions ConfigureOptimisticConcurrencyRetry(int retries, TimeSpan delayBeforeRetry);
IEventFlowOptions Configure(Action<EventFlowConfiguration> configure);
IEventFlowOptions AddEvents(IEnumerable<Type> aggregateEventTypes);
Expand Down
3 changes: 2 additions & 1 deletion Source/EventFlow/ReadStores/ReadModelFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ public Task<TReadModel> CreateAsync(string id, CancellationToken cancellationTok
{
_logger.LogTrace(
"Creating new instance of read model type {ReadModelType} with ID {Id}",
typeof(TReadModel).PrettyPrint());
typeof(TReadModel).PrettyPrint(),
id);
}

var readModel = (TReadModel) Activator.CreateInstance(typeof(TReadModel));
Expand Down

0 comments on commit d93b883

Please sign in to comment.