Skip to content

Commit

Permalink
Upgraded Marten and ESDB client to the latest versions
Browse files Browse the repository at this point in the history
Bumped also other dependencies
  • Loading branch information
oskardudycz committed Apr 24, 2024
1 parent 9b02842 commit 21a7002
Show file tree
Hide file tree
Showing 141 changed files with 504 additions and 538 deletions.
2 changes: 1 addition & 1 deletion Core.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
<AnalysisLevel>latest</AnalysisLevel>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.8.14" PrivateAssets="All"/>
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.9.28" PrivateAssets="All"/>
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion Core.ElasticSearch/Core.ElasticSearch.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


<ItemGroup>
<PackageReference Include="Elastic.Clients.Elasticsearch" Version="8.12.0" />
<PackageReference Include="Elastic.Clients.Elasticsearch" Version="8.13.10" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
Expand Down
2 changes: 1 addition & 1 deletion Core.EventStoreDB.Tests/Core.EventStoreDB.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.0" />
<PackageReference Include="xunit" Version="2.6.6" />
<PackageReference Include="xunit" Version="2.7.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
Expand Down
4 changes: 2 additions & 2 deletions Core.EventStoreDB/Core.EventStoreDB.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@


<ItemGroup>
<PackageReference Include="EventStore.Client.Grpc.Streams" Version="23.1.0" />
<PackageReference Include="EventStore.Client.Grpc.Streams" Version="23.2.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
Expand Down
31 changes: 21 additions & 10 deletions Core.EventStoreDB/Subscriptions/EventStoreDBSubscriptionToAll.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,33 @@ public async Task SubscribeToAll(EventStoreDBSubscriptionToAllOptions subscripti

var checkpoint = await checkpointRepository.Load(SubscriptionId, ct).ConfigureAwait(false);

await eventStoreClient.SubscribeToAllAsync(
checkpoint == null ? FromAll.Start : FromAll.After(new Position(checkpoint.Value, checkpoint.Value)),
HandleEvent,
var subscription = eventStoreClient.SubscribeToAll(
checkpoint == null
? FromAll.Start
: FromAll.After(new Position(checkpoint.Value, checkpoint.Value)),
subscriptionOptions.ResolveLinkTos,
HandleDrop,
subscriptionOptions.FilterOptions,
subscriptionOptions.Credentials,
ct
).ConfigureAwait(false);
);

logger.LogInformation("Subscription to all '{SubscriptionId}' started", SubscriptionId);

try
{
await foreach (var @event in subscription)
{
await HandleEvent(@event, ct).ConfigureAwait(false);
}
}
catch (Exception ex)
{
HandleDrop(ex);
}

}

private async Task HandleEvent(
StreamSubscription subscription,
ResolvedEvent resolvedEvent,
CancellationToken token
)
Expand Down Expand Up @@ -135,7 +147,7 @@ await checkpointRepository.Store(SubscriptionId, resolvedEvent.Event.Position.Co
}
}

private void HandleDrop(StreamSubscription _, SubscriptionDroppedReason reason, Exception? exception)
private void HandleDrop(Exception? exception)
{
if (exception is RpcException { StatusCode: StatusCode.Cancelled })
{
Expand All @@ -149,10 +161,9 @@ private void HandleDrop(StreamSubscription _, SubscriptionDroppedReason reason,

logger.LogError(
exception,
"Subscription to all '{SubscriptionId}' dropped with '{StatusCode}' and '{Reason}'",
"Subscription to all '{SubscriptionId}' dropped with '{StatusCode}'",
SubscriptionId,
(exception as RpcException)?.StatusCode ?? StatusCode.Unknown,
reason
(exception as RpcException)?.StatusCode ?? StatusCode.Unknown
);


Expand Down
2 changes: 1 addition & 1 deletion Core.Kafka.Tests/Core.Kafka.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.0" />
<PackageReference Include="xunit" Version="2.6.6" />
<PackageReference Include="xunit" Version="2.7.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
Expand Down
2 changes: 1 addition & 1 deletion Core.Kafka/Core.Kafka.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<ItemGroup>
<PackageReference Include="Confluent.Kafka" Version="2.3.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions Core.Marten/Core.Marten.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Marten" Version="7.0.0-beta.5" />
<PackageReference Include="Marten" Version="7.8.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
5 changes: 1 addition & 4 deletions Core.Marten/MartenConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,7 @@ public static class MartenConfigExtensions
options.Events.DatabaseSchemaName = schemaName ?? martenConfig.WriteModelSchema;
options.DatabaseSchemaName = schemaName ?? martenConfig.ReadModelSchema;

options.UseDefaultSerialization(
EnumStorage.AsString,
nonPublicMembersStorage: NonPublicMembersStorage.All
);
options.UseSystemTextJsonForSerialization(EnumStorage.AsString);

options.Projections.Add(
new MartenSubscription(
Expand Down
8 changes: 4 additions & 4 deletions Core.Testing/Core.Testing.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Bogus" Version="35.4.0" />
<PackageReference Include="Bogus" Version="35.5.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Open.ChannelExtensions" Version="8.0.2" />
<PackageReference Include="xunit" Version="2.6.6" />
<PackageReference Include="xunit" Version="2.7.1" />
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="8.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.4" />
<PackageReference Include="Ogooreck" Version="0.8.0" />
</ItemGroup>

Expand Down
4 changes: 2 additions & 2 deletions Core.Tests/Core.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Marten" Version="7.0.0-beta.3" />
<PackageReference Include="Marten" Version="7.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.0" />
<PackageReference Include="xunit" Version="2.6.6" />
<PackageReference Include="xunit" Version="2.7.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
Expand Down
2 changes: 1 addition & 1 deletion Core.WebApi/Core.WebApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.4" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>

Expand Down
14 changes: 7 additions & 7 deletions Core/Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Polly" Version="8.2.1" />
<PackageReference Include="Polly" Version="8.3.1" />
<PackageReference Include="RestSharp" Version="110.2.0" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.7.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.7.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.7.0" />
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.7.0" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.8.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.8.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.8.1" />
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.8.1" />
<PackageReference Include="Scrutor" Version="4.2.2" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Marten" Version="7.0.0-beta.5" />
<PackageReference Include="Marten" Version="7.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.0" />
<PackageReference Include="xunit" Version="2.6.6" />
<PackageReference Include="xunit" Version="2.7.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Core.Testing;
using FluentAssertions;
using Marten.Events.Daemon;
using Marten.Events.Daemon.Coordination;
using Marten.Integration.Tests.TestsInfrastructure;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
Expand Down Expand Up @@ -79,15 +80,15 @@ public override async Task InitializeAsync()
var serviceProvider = services.BuildServiceProvider();
var session = serviceProvider.GetRequiredService<IDocumentSession>();

asyncDaemon = (AsyncProjectionHostedService)serviceProvider.GetRequiredService<IHostedService>();
asyncDaemon = serviceProvider.GetRequiredService<ProjectionCoordinator>();

martenAsyncCommandBus = new MartenAsyncCommandBus(session);
}

private MartenAsyncCommandBus martenAsyncCommandBus = default!;
private readonly List<Guid> userIds = new();
private readonly EventListener eventListener = new();
private AsyncProjectionHostedService asyncDaemon = default!;
private ProjectionCoordinator asyncDaemon = default!;
private readonly CancellationToken ct = new CancellationTokenSource().Token;

public MartenAsyncCommandBusTests(MartenFixture fixture) : base(fixture.PostgreSqlContainer, true)
Expand Down
2 changes: 1 addition & 1 deletion Marten.Integration.Tests/CompositeIds/CompositeIdsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ protected override IDocumentSession CreateSession(Action<StoreOptions>? setStore
options.AutoCreateSchemaObjects = AutoCreate.All;
options.DatabaseSchemaName = SchemaName;
options.Events.DatabaseSchemaName = SchemaName;
options.UseDefaultSerialization(nonPublicMembersStorage: NonPublicMembersStorage.All);
options.UseNewtonsoftForSerialization(nonPublicMembersStorage: NonPublicMembersStorage.All);
options.Projections.Snapshot<Reservation>(SnapshotLifecycle.Inline);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,11 @@ public enum ChangeType

public record DocumentChanged(ChangeType ChangeType, object Data);

public class AsyncListenerWrapper: IChangeListener
public class AsyncListenerWrapper(EventListener eventListener, IChangeListener inner): IChangeListener
{
private readonly EventListener eventListener;
private readonly IChangeListener inner;

public AsyncListenerWrapper(EventListener eventListener, IChangeListener inner)
{
this.eventListener = eventListener;
this.inner = inner;
}

public async Task AfterCommitAsync(IDocumentSession session, IChangeSet commit, CancellationToken token)
public async Task BeforeCommitAsync(IDocumentSession session, IChangeSet commit, CancellationToken token)
{
await inner.AfterCommitAsync(session, commit, token);
await inner.BeforeCommitAsync(session, commit, token);

foreach (var @event in commit.Inserted.Select(doc => new DocumentChanged(ChangeType.Insert, doc))
.Union(commit.Updated.Select(doc => new DocumentChanged(ChangeType.Update, doc)))
Expand All @@ -93,16 +84,14 @@ public async Task AfterCommitAsync(IDocumentSession session, IChangeSet commit,
await eventListener.Handle(@event, token);
}
}

public Task AfterCommitAsync(IDocumentSession session, IChangeSet commit, CancellationToken token) =>
Task.CompletedTask;
}

public class AsyncDocumentChangesForwarder: IChangeListener
public class AsyncDocumentChangesForwarder(IMessagingSystem messagingSystem): IChangeListener
{
private readonly IMessagingSystem messagingSystem;

public AsyncDocumentChangesForwarder(IMessagingSystem messagingSystem) =>
this.messagingSystem = messagingSystem;

public Task AfterCommitAsync(IDocumentSession session, IChangeSet commit, CancellationToken token)
public Task BeforeCommitAsync(IDocumentSession session, IChangeSet commit, CancellationToken token)
{
var changes = commit.Inserted.Select(doc => new DocumentChanged(ChangeType.Insert, doc))
.Union(commit.Updated.Select(doc => new DocumentChanged(ChangeType.Update, doc)))
Expand All @@ -111,9 +100,12 @@ public Task AfterCommitAsync(IDocumentSession session, IChangeSet commit, Cancel

return messagingSystem.Publish(changes.Cast<object>().ToArray(), token);
}

public Task AfterCommitAsync(IDocumentSession session, IChangeSet commit, CancellationToken token) =>
Task.CompletedTask;
}

public class DocumentChangesForwarding: MartenTest
public class DocumentChangesForwarding(MartenFixture fixture): MartenTest(fixture.PostgreSqlContainer, false, false)
{
[Fact(Skip = "Some weird is happening in System channels")]
public async Task GivenEvents_WhenInlineTransformationIsApplied_ThenReturnsSameNumberOfTransformedItems()
Expand Down Expand Up @@ -154,9 +146,6 @@ public override async Task InitializeAsync()
new AsyncDocumentChangesForwarder(messagingSystemStub)
)
);
options.Projections.OnException<InvalidOperationException>()
.RetryLater(50.Milliseconds(), 250.Milliseconds(), 500.Milliseconds());
}).AddAsyncDaemon(DaemonMode.Solo)
.UseLightweightSessions();

Expand All @@ -179,9 +168,4 @@ public override async Task DisposeAsync()

await base.DisposeAsync();
}

public DocumentChangesForwarding(MartenFixture fixture) : base(fixture.PostgreSqlContainer, false, false)
{

}
}
Loading

0 comments on commit 21a7002

Please sign in to comment.