Skip to content

Commit d93b883

Browse files
authored
Merge pull request #899 from eventflow/fix-missing-id-in-log
Fix missing id in log
2 parents b03967c + f866bc8 commit d93b883

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

Source/EventFlow/EventFlowOptions.cs

+13-8
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2323

2424
using System;
25+
using System.Collections.Concurrent;
2526
using System.Collections.Generic;
26-
using System.Linq;
2727
using System.Reflection;
2828
using EventFlow.Aggregates;
2929
using EventFlow.Commands;
@@ -53,11 +53,11 @@ namespace EventFlow
5353
{
5454
public class EventFlowOptions : IEventFlowOptions
5555
{
56-
private readonly List<Type> _aggregateEventTypes = new List<Type>();
57-
private readonly List<Type> _sagaTypes = new List<Type>();
58-
private readonly List<Type> _commandTypes = new List<Type>();
56+
private readonly ConcurrentBag<Type> _aggregateEventTypes = new ConcurrentBag<Type>();
57+
private readonly ConcurrentBag<Type> _sagaTypes = new ConcurrentBag<Type>();
58+
private readonly ConcurrentBag<Type> _commandTypes = new ConcurrentBag<Type>();
5959
private readonly EventFlowConfiguration _eventFlowConfiguration = new EventFlowConfiguration();
60-
private readonly List<Type> _jobTypes = new List<Type>
60+
private readonly ConcurrentBag<Type> _jobTypes = new ConcurrentBag<Type>
6161
{
6262
typeof(PublishCommandJob),
6363
typeof(DispatchToAsynchronousEventSubscribersJob)
@@ -73,8 +73,13 @@ private EventFlowOptions(IServiceCollection serviceCollection)
7373
RegisterDefaults(ServiceCollection);
7474
}
7575

76-
public static IEventFlowOptions New() => new EventFlowOptions(new ServiceCollection()
77-
.AddLogging(b => b.AddConsole()));
76+
public static IEventFlowOptions New() =>
77+
new EventFlowOptions(
78+
new ServiceCollection()
79+
.AddLogging(b => b
80+
.SetMinimumLevel(LogLevel.Trace)
81+
.AddConsole()));
82+
7883
public static IEventFlowOptions New(IServiceCollection serviceCollection) => new EventFlowOptions(serviceCollection);
7984

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

215-
serviceCollection.AddSingleton<ILoadedVersionedTypes>(r => new LoadedVersionedTypes(
220+
serviceCollection.TryAddSingleton<ILoadedVersionedTypes>(r => new LoadedVersionedTypes(
216221
_jobTypes,
217222
_commandTypes,
218223
_aggregateEventTypes,

Source/EventFlow/IEventFlowOptions.cs

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public interface IEventFlowOptions
3232
{
3333
IServiceCollection ServiceCollection { get; }
3434

35+
IEventFlowOptions ConfigureThrowSubscriberExceptions(bool shouldThrow);
3536
IEventFlowOptions ConfigureOptimisticConcurrencyRetry(int retries, TimeSpan delayBeforeRetry);
3637
IEventFlowOptions Configure(Action<EventFlowConfiguration> configure);
3738
IEventFlowOptions AddEvents(IEnumerable<Type> aggregateEventTypes);

Source/EventFlow/ReadStores/ReadModelFactory.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ public Task<TReadModel> CreateAsync(string id, CancellationToken cancellationTok
6666
{
6767
_logger.LogTrace(
6868
"Creating new instance of read model type {ReadModelType} with ID {Id}",
69-
typeof(TReadModel).PrettyPrint());
69+
typeof(TReadModel).PrettyPrint(),
70+
id);
7071
}
7172

7273
var readModel = (TReadModel) Activator.CreateInstance(typeof(TReadModel));

0 commit comments

Comments
 (0)