diff --git a/Samples/ASP.NET/ASP.NET.csproj b/Samples/ASP.NET/ASP.NET.csproj
index f1585072..157e5177 100644
--- a/Samples/ASP.NET/ASP.NET.csproj
+++ b/Samples/ASP.NET/ASP.NET.csproj
@@ -5,6 +5,7 @@
+
diff --git a/Samples/ASP.NET/Dockerfile b/Samples/ASP.NET/Dockerfile
deleted file mode 100644
index 359af876..00000000
--- a/Samples/ASP.NET/Dockerfile
+++ /dev/null
@@ -1,31 +0,0 @@
-# DotNet Build
-FROM mcr.microsoft.com/dotnet/sdk:7.0 AS dotnet-build
-SHELL ["/bin/bash", "-c"]
-
-COPY base.props /app/
-COPY default.props /app/
-COPY netstandard.props /app/
-COPY versions.props /app/
-COPY DotNET.SDK.sln /app/
-COPY LegacySupport /app
-COPY Source /app/Source/
-COPY Samples/ASP.NET /app/Samples/ASP.NET
-
-WORKDIR /app/Samples/ASP.NET
-RUN dotnet restore
-RUN dotnet publish -c "Release" -o out
-
-# Runtime Image
-FROM mcr.microsoft.com/dotnet/aspnet:7.0
-SHELL ["/bin/bash", "-c"]
-
-ENV Logging__Console__FormatterName=""
-
-WORKDIR /app
-COPY --from=dotnet-build /app/Samples/ASP.NET/out ./
-
-EXPOSE 5000 5001
-
-ENTRYPOINT ["dotnet", "ASP.NET.dll"]
-
-#dotnet-aspnet-sample:0.0.2
diff --git a/Source/Aggregates/Actors/AggregateActor.cs b/Source/Aggregates/Actors/AggregateActor.cs
index fd4d93cf..a36ae93a 100644
--- a/Source/Aggregates/Actors/AggregateActor.cs
+++ b/Source/Aggregates/Actors/AggregateActor.cs
@@ -80,7 +80,6 @@ async Task OnStarted(IContext context)
try
{
var (tenantId, eventSourceId) = GetIdentifiers(context);
-
_eventSourceId = eventSourceId;
var serviceProvider = await _getServiceProvider(tenantId);
_aggregateWrapper = ActivatorUtilities.CreateInstance>(serviceProvider, _eventSourceId);
diff --git a/Source/Aggregates/Internal/AggregateWrapper.cs b/Source/Aggregates/Internal/AggregateWrapper.cs
index 65dc430a..588950ea 100644
--- a/Source/Aggregates/Internal/AggregateWrapper.cs
+++ b/Source/Aggregates/Internal/AggregateWrapper.cs
@@ -11,6 +11,7 @@
using Dolittle.SDK.Events.Builders;
using Dolittle.SDK.Events.Store;
using Dolittle.SDK.Events.Store.Builders;
+using Dolittle.SDK.Tenancy;
using Microsoft.Extensions.Logging;
#pragma warning disable CS0618 // Refers to EventSourceId which is marked obsolete for clients. Should still be used internally
@@ -23,6 +24,7 @@ namespace Dolittle.SDK.Aggregates.Internal;
class AggregateWrapper where TAggregate : AggregateRoot
{
readonly EventSourceId _eventSourceId;
+ readonly TenantId _tenant;
readonly IEventStore _eventStore;
readonly IEventTypes _eventTypes;
readonly IServiceProvider _serviceProvider;
@@ -34,13 +36,15 @@ class AggregateWrapper where TAggregate : AggregateRoot
/// Initializes a new instance of the class.
///
/// The of the aggregate root instance.
+ /// The tenant id.
/// The used for committing the when actions are performed on the aggregate.
/// The .
/// The tenant scoped .
/// The .
- public AggregateWrapper(EventSourceId eventSourceId, IEventStore eventStore, IEventTypes eventTypes, IServiceProvider serviceProvider, ILogger> logger)
+ public AggregateWrapper(EventSourceId eventSourceId, TenantId tenant, IEventStore eventStore, IEventTypes eventTypes, IServiceProvider serviceProvider, ILogger> logger)
{
_eventSourceId = eventSourceId;
+ _tenant = tenant;
_eventTypes = eventTypes;
_eventStore = eventStore;
_serviceProvider = serviceProvider;
@@ -57,7 +61,7 @@ public async Task Perform(Func method, CancellationToken cance
_instance = await GetHydratedAggregate(cancellationToken);
var aggregateRootId = _instance.AggregateRootId;
activity?.Tag(aggregateRootId);
- _logger.PerformingOn(typeof(TAggregate), aggregateRootId, _instance.EventSourceId);
+ _logger.PerformingOn(typeof(TAggregate), aggregateRootId, _instance.EventSourceId, _tenant);
await method(_instance);
if (_instance.AppliedEvents.Any())
{
@@ -97,7 +101,7 @@ bool TryGetAggregateRoot(out TAggregate aggregateRoot, out Exception exception)
Task Rehydrate(TAggregate aggregateRoot, AggregateRootId aggregateRootId, CancellationToken cancellationToken)
{
var eventSourceId = aggregateRoot.EventSourceId;
- _logger.RehydratingAggregateRoot(typeof(TAggregate), aggregateRootId, eventSourceId);
+ _logger.RehydratingAggregateRoot(typeof(TAggregate), aggregateRootId, eventSourceId, _tenant);
var eventTypesToFetch = GetEventTypes(_eventTypes);
var committedEventsBatches = _eventStore.FetchStreamForAggregate(aggregateRootId, eventSourceId, eventTypesToFetch, cancellationToken);
return aggregateRoot.RehydrateInternal(committedEventsBatches, AggregateRootMetadata.MethodsPerEventType, cancellationToken);
@@ -117,7 +121,7 @@ static IEnumerable GetEventTypes(IEventTypes eventTypes)
Task CommitAppliedEvents(TAggregate aggregateRoot, AggregateRootId aggregateRootId)
{
- _logger.CommittingEvents(aggregateRoot.GetType(), aggregateRootId, aggregateRoot.AppliedEvents.Count(), aggregateRoot.EventSourceId);
+ _logger.CommittingEvents(aggregateRoot.GetType(), aggregateRootId, aggregateRoot.AppliedEvents.Count(), aggregateRoot.EventSourceId, _tenant);
return _eventStore
.ForAggregate(aggregateRootId)
.WithEventSource(aggregateRoot.EventSourceId)
diff --git a/Source/Aggregates/Log.cs b/Source/Aggregates/Log.cs
index 0558f032..f2892473 100644
--- a/Source/Aggregates/Log.cs
+++ b/Source/Aggregates/Log.cs
@@ -3,6 +3,7 @@
using System;
using Dolittle.SDK.Events;
+using Dolittle.SDK.Tenancy;
using Microsoft.Extensions.Logging;
namespace Dolittle.SDK.Aggregates;
@@ -13,11 +14,11 @@ namespace Dolittle.SDK.Aggregates;
static partial class Log
{
[LoggerMessage(0, LogLevel.Debug,
- "Performing operation on {AggregateRoot} with aggregate root id {AggregateRootId} applying events to event source {EventSource}")]
- internal static partial void PerformingOn(this ILogger logger, Type aggregateRoot, AggregateRootId aggregateRootId, EventSourceId eventSource);
+ "Performing operation on {AggregateRoot} with aggregate root id {AggregateRootId} applying events to event source {EventSource} for tenant {Tenant}")]
+ internal static partial void PerformingOn(this ILogger logger, Type aggregateRoot, AggregateRootId aggregateRootId, EventSourceId eventSource, TenantId tenant);
- [LoggerMessage(0, LogLevel.Debug, "Rehydrating {AggregateRoot} with aggregate root id {AggregateRootId} with event source id {EventSource}")]
- internal static partial void RehydratingAggregateRoot(this ILogger logger, Type aggregateRoot, AggregateRootId aggregateRootId, EventSourceId eventSource);
+ [LoggerMessage(0, LogLevel.Debug, "Rehydrating {AggregateRoot} with aggregate root id {AggregateRootId} with event source id {EventSource} for tenant {Tenant}")]
+ internal static partial void RehydratingAggregateRoot(this ILogger logger, Type aggregateRoot, AggregateRootId aggregateRootId, EventSourceId eventSource, TenantId tenant);
[LoggerMessage(0, LogLevel.Trace, "Re-applying {NumberOfEvents} events")]
internal static partial void ReApplying(this ILogger logger, int numberOfEvents);
@@ -26,9 +27,9 @@ static partial class Log
internal static partial void NoEventsToReApply(this ILogger logger);
[LoggerMessage(0, LogLevel.Debug,
- "{AggregateRoot} with aggregate root id {AggregateRootId} is committing {NumberOfEvents} events to event source {EventSource}")]
+ "{AggregateRoot} with aggregate root id {AggregateRootId} is committing {NumberOfEvents} events to event source {EventSource} for tenant {Tenant}")]
internal static partial void CommittingEvents(this ILogger logger, Type aggregateRoot, AggregateRootId aggregateRootId, int numberOfEvents,
- EventSourceId eventSource);
+ EventSourceId eventSource, TenantId tenant);
[LoggerMessage(0, LogLevel.Error, "{AggregateRoot} failed to instantiate")]
internal static partial void FailedToCreate(this ILogger logger, Exception e, Type aggregateRoot);
diff --git a/Source/Events/Store/Internal/AggregateEventCommitter.cs b/Source/Events/Store/Internal/AggregateEventCommitter.cs
index a72dfb1c..495198ee 100644
--- a/Source/Events/Store/Internal/AggregateEventCommitter.cs
+++ b/Source/Events/Store/Internal/AggregateEventCommitter.cs
@@ -63,7 +63,8 @@ public async Task CommitForAggregate(UncommittedAggreg
_logger.CommittingAggregateEvents(uncommittedAggregateEvents.Count,
uncommittedAggregateEvents.AggregateRoot,
uncommittedAggregateEvents.EventSource,
- uncommittedAggregateEvents.ExpectedAggregateRootVersion);
+ uncommittedAggregateEvents.ExpectedAggregateRootVersion,
+ _executionContext.Tenant);
if (!_toProtobuf.TryConvert(uncommittedAggregateEvents, out var protobufEvents, out var error))
{
diff --git a/Source/Events/Store/Internal/EventCommitter.cs b/Source/Events/Store/Internal/EventCommitter.cs
index cda20840..4f933f10 100644
--- a/Source/Events/Store/Internal/EventCommitter.cs
+++ b/Source/Events/Store/Internal/EventCommitter.cs
@@ -60,7 +60,7 @@ public async Task Commit(UncommittedEvents uncommittedEvents, C
try
{
- _logger.CommittingEvents(uncommittedEvents.Count);
+ _logger.CommittingEvents(uncommittedEvents.Count, _executionContext.Tenant);
if (!_toProtobuf.TryConvert(uncommittedEvents, out var protobufEvents, out var error))
{
diff --git a/Source/Events/Store/Internal/EventsForAggregateFetcher.cs b/Source/Events/Store/Internal/EventsForAggregateFetcher.cs
index 9f4a0919..d9c8524c 100644
--- a/Source/Events/Store/Internal/EventsForAggregateFetcher.cs
+++ b/Source/Events/Store/Internal/EventsForAggregateFetcher.cs
@@ -57,7 +57,7 @@ public Task FetchForAggregate(
EventSourceId eventSourceId,
CancellationToken cancellationToken = default)
{
- _logger.FetchingAllEventsForAggregate(aggregateRootId, eventSourceId);
+ _logger.FetchingAllEventsForAggregate(aggregateRootId, eventSourceId, _executionContext.Tenant);
var request = CreateFetchRequestBase(aggregateRootId, eventSourceId);
request.FetchAllEvents = new FetchAllEventsForAggregateInBatchesRequest();
return AggregateBatches(eventSourceId, aggregateRootId, DoFetchForAggregate(request, cancellationToken));
@@ -70,7 +70,7 @@ public Task FetchForAggregate(
IEnumerable eventTypes,
CancellationToken cancellationToken = default)
{
- _logger.FetchingEventsForAggregate(aggregateRootId, eventSourceId, eventTypes);
+ _logger.FetchingEventsForAggregate(aggregateRootId, eventSourceId, eventTypes, _executionContext.Tenant);
var request = CreateFetchRequestBase(aggregateRootId, eventSourceId);
request.FetchEvents = new FetchEventsForAggregateInBatchesRequest
{
@@ -82,7 +82,7 @@ public Task FetchForAggregate(
///
public IAsyncEnumerable FetchStreamForAggregate(AggregateRootId aggregateRootId, EventSourceId eventSourceId, CancellationToken cancellationToken = default)
{
- _logger.FetchingAllEventsForAggregate(aggregateRootId, eventSourceId);
+ _logger.FetchingAllEventsForAggregate(aggregateRootId, eventSourceId, _executionContext.Tenant);
var request = CreateFetchRequestBase(aggregateRootId, eventSourceId);
request.FetchAllEvents = new FetchAllEventsForAggregateInBatchesRequest();
return DoFetchForAggregate(request, cancellationToken);
@@ -91,7 +91,7 @@ public IAsyncEnumerable FetchStreamForAggregate(Aggreg
///
public IAsyncEnumerable FetchStreamForAggregate(AggregateRootId aggregateRootId, EventSourceId eventSourceId, IEnumerable eventTypes, CancellationToken cancellationToken = default)
{
- _logger.FetchingEventsForAggregate(aggregateRootId, eventSourceId, eventTypes);
+ _logger.FetchingEventsForAggregate(aggregateRootId, eventSourceId, eventTypes, _executionContext.Tenant);
var request = CreateFetchRequestBase(aggregateRootId, eventSourceId);
request.FetchEvents = new FetchEventsForAggregateInBatchesRequest
{
diff --git a/Source/Events/Store/Internal/Log.cs b/Source/Events/Store/Internal/Log.cs
index adfebe77..dc2a49ed 100644
--- a/Source/Events/Store/Internal/Log.cs
+++ b/Source/Events/Store/Internal/Log.cs
@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
+using Dolittle.SDK.Tenancy;
using Microsoft.Extensions.Logging;
namespace Dolittle.SDK.Events.Store.Internal;
@@ -12,11 +13,11 @@ namespace Dolittle.SDK.Events.Store.Internal;
///
static partial class Log
{
- [LoggerMessage(0, LogLevel.Debug, "Committing {NumberOfEvents} events for aggregate root type {AggregateRoot} and id {EventSource} with expected version {ExpectedVersion}")]
- internal static partial void CommittingAggregateEvents(this ILogger logger, int numberOfEvents, AggregateRootId aggregateRoot, EventSourceId eventSource, AggregateRootVersion expectedVersion);
+ [LoggerMessage(0, LogLevel.Debug, "Committing {NumberOfEvents} events for aggregate root type {AggregateRoot} and id {EventSource} with expected version {ExpectedVersion} to tenant {Tenant}")]
+ internal static partial void CommittingAggregateEvents(this ILogger logger, int numberOfEvents, AggregateRootId aggregateRoot, EventSourceId eventSource, AggregateRootVersion expectedVersion, TenantId tenant);
- [LoggerMessage(0, LogLevel.Debug, "Committing {NumberOfEvents} events")]
- internal static partial void CommittingEvents(this ILogger logger, int numberOfEvents);
+ [LoggerMessage(0, LogLevel.Debug, "Committing {NumberOfEvents} events to tenant {Tenant}")]
+ internal static partial void CommittingEvents(this ILogger logger, int numberOfEvents, TenantId tenant);
[LoggerMessage(0, LogLevel.Error, "Could not convert UncommittedAggregateEvents to Protobuf.")]
internal static partial void UncommittedAggregateEventsCouldNotBeConverted(this ILogger logger, Exception ex);
@@ -30,11 +31,11 @@ static partial class Log
[LoggerMessage(0, LogLevel.Error, "The Runtime acknowledges that the events have been committed, but the returned CommittedEvents could not be converted.")]
internal static partial void CommittedEventsCouldNotBeConverted(this ILogger logger, Exception ex);
- [LoggerMessage(0, LogLevel.Debug, "Fetching all events for aggregate root {AggregateRoot} and event source {EventSource}")]
- internal static partial void FetchingAllEventsForAggregate(this ILogger logger, AggregateRootId aggregateRoot, EventSourceId eventSource);
+ [LoggerMessage(0, LogLevel.Debug, "Fetching all events from tenant {Tenant} for aggregate root {AggregateRoot} and event source {EventSource}")]
+ internal static partial void FetchingAllEventsForAggregate(this ILogger logger, AggregateRootId aggregateRoot, EventSourceId eventSource, TenantId tenant);
- [LoggerMessage(0, LogLevel.Debug, "Fetching events for aggregate root {AggregateRoot} and event source {EventSource} that is of one of the following event types: [{EventTypes}]")]
- internal static partial void FetchingEventsForAggregate(this ILogger logger, AggregateRootId aggregateRoot, EventSourceId eventSource, IEnumerable eventTypes);
+ [LoggerMessage(0, LogLevel.Debug, "Fetching events from tenant {Tenant} for aggregate root {AggregateRoot} and event source {EventSource} that is of one of the following event types: [{EventTypes}")]
+ internal static partial void FetchingEventsForAggregate(this ILogger logger, AggregateRootId aggregateRoot, EventSourceId eventSource, IEnumerable eventTypes, TenantId tenant);
[LoggerMessage(0, LogLevel.Error, "Could not convert CommittedAggregateEvents to SDK.")]
internal static partial void FetchedEventsForAggregateCouldNotBeConverted(this ILogger logger, Exception ex);
diff --git a/Source/SDK/DolittleClient.cs b/Source/SDK/DolittleClient.cs
index 7a6f7249..af299bf8 100644
--- a/Source/SDK/DolittleClient.cs
+++ b/Source/SDK/DolittleClient.cs
@@ -224,32 +224,29 @@ public async Task Connect(DolittleClientConfiguration configura
}
AddDefaultsFromServiceProviderInConfiguration(configuration);
-
- var loggerFactory = configuration.LoggerFactory;
- if (loggerFactory is not null)
- {
- _buildResults.WriteTo(loggerFactory.CreateLogger());
- }
-
+ var loggerFactory = configuration.LoggerFactory ?? LoggerFactory.Create(_ => _.AddConsole());
+ _buildResults.WriteTo(loggerFactory.CreateLogger());
_grpcChannel = GrpcChannel.ForAddress(
- $"http://{configuration.RuntimeHost}:{configuration.RuntimePort}",
- new GrpcChannelOptions
- {
- Credentials = ChannelCredentials.Insecure,
- MaxReceiveMessageSize = 32 * 1024 * 1024,
- MaxSendMessageSize = 32 * 1024 * 1024,
+ $"http://{configuration.RuntimeHost}:{configuration.RuntimePort}",
+ new GrpcChannelOptions
+ {
+ Credentials = ChannelCredentials.Insecure,
+ MaxReceiveMessageSize = 32 * 1024 * 1024,
+ MaxSendMessageSize = 32 * 1024 * 1024,
#if NET5_0_OR_GREATER
- HttpHandler = new SocketsHttpHandler
- {
- EnableMultipleHttp2Connections = true
- }
+ HttpHandler = new SocketsHttpHandler
+ {
+ EnableMultipleHttp2Connections = true
+ }
#endif
- });
+ });
var methodCaller = new MethodCaller(_grpcChannel, configuration.RuntimeHost, configuration.RuntimePort);
var (executionContext, tenants, otlpEndpoint) =
await ConnectToRuntime(methodCaller, configuration, loggerFactory, cancellationToken).ConfigureAwait(false);
Tenants = tenants;
-
+#pragma warning disable CA1848
+ loggerFactory.CreateLogger().LogDebug("Configured tenants:\n{TenantListString}", string.Join('\n', tenants.Select(_ => $"\t{_.Id}")));
+#pragma warning restore CA1848
await CreateDependencies(methodCaller, configuration.EventSerializerProvider, loggerFactory, executionContext, tenants).ConfigureAwait(false);
ConfigureContainer(configuration);
await RegisterAllUnregistered(methodCaller, configuration.PingInterval, executionContext, loggerFactory).ConfigureAwait(false);