diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 504b15872..772670d8b 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -26,12 +26,12 @@ jobs: fetch-depth: 0 - name: Setup .NET - uses: actions/setup-dotnet@v4 + uses: actions/setup-dotnet@v5 with: - dotnet-version: '9.0.x' + dotnet-version: '10.0.x' - name: Run tests - run: dotnet test --framework net9.0 + run: dotnet test --framework net10.0 - name: Publish test results uses: EnricoMi/publish-unit-test-result-action/linux@v2 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 3f1721489..75d79ccb0 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -20,6 +20,11 @@ jobs: uses: actions/setup-python@v6 with: python-version: 3.8 + - + name: Setup .NET + uses: actions/setup-dotnet@v5 + with: + dotnet-version: '10.0.x' - name: Checkout code uses: actions/checkout@v5 @@ -27,7 +32,7 @@ jobs: fetch-depth: 0 - name: Run tests - run: dotnet test --framework net9.0 + run: dotnet test --framework net10.0 - name: Publish test results uses: EnricoMi/publish-unit-test-result-action/linux@v2 diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index fa76ff4d7..889aa2eb5 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -37,13 +37,7 @@ jobs: dotnet-version: | 8.0 9.0 - - - name: Setup .NET 10 - uses: actions/setup-dotnet@v5 - with: - dotnet-version: | 10.0 - dotnet-quality: 'preview' - name: Login to Docker Hub if: ${{ github.event.pull_request.head.repo.fork == false }} diff --git a/Directory.Packages.props b/Directory.Packages.props index 5bd2b3ee2..c48a65ecc 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -24,6 +24,7 @@ + diff --git a/Eventuous.slnx b/Eventuous.slnx index 922154cfc..9866ba984 100644 --- a/Eventuous.slnx +++ b/Eventuous.slnx @@ -1,163 +1,163 @@ - - - - - - + + + + + + - + - - + + - + - + - + - - + + - + - + - + - + - + - + - + - + - + - - - - - - - - - + + + + + + + + + - - - - - + + + + + - + - - + + - + - - - - - - - - + - - - - + + + + - + - + - - - - + + + + - - - + + + - + - + - + + + + + + + + - + - + - + - - + + - + - - + + - + - + - + - + - + - + - - - + + + - - - + + + - + - + - - - - + + + + \ No newline at end of file diff --git a/samples/esdb/Bookings.Payments/Bookings.Payments.csproj b/samples/esdb/Bookings.Payments/Bookings.Payments.csproj index 3f40ac9a3..a604b03a8 100644 --- a/samples/esdb/Bookings.Payments/Bookings.Payments.csproj +++ b/samples/esdb/Bookings.Payments/Bookings.Payments.csproj @@ -24,7 +24,7 @@ - + diff --git a/samples/esdb/Bookings.Payments/Integration/Payments.cs b/samples/esdb/Bookings.Payments/Integration/Payments.cs index 70bdfc050..737f05738 100644 --- a/samples/esdb/Bookings.Payments/Integration/Payments.cs +++ b/samples/esdb/Bookings.Payments/Integration/Payments.cs @@ -1,6 +1,6 @@ using Bookings.Payments.Domain; using Eventuous; -using Eventuous.EventStore.Producers; +using Eventuous.KurrentDB.Producers; using Eventuous.Gateway; using Eventuous.Subscriptions.Context; using static Bookings.Payments.Integration.IntegrationEvents; @@ -11,16 +11,16 @@ namespace Bookings.Payments.Integration; public static class PaymentsGateway { static readonly StreamName Stream = new("PaymentsIntegration"); - public static ValueTask[]> Transform(IMessageConsumeContext original) { + public static ValueTask[]> Transform(IMessageConsumeContext original) { var result = original.Message is PaymentEvents.PaymentRecorded evt - ? new GatewayMessage( + ? new GatewayMessage( Stream, new BookingPaymentRecorded(original.Stream.GetId(), evt.BookingId, evt.Amount, evt.Currency), - new Metadata(), - new EventStoreProduceOptions() + new(), + new() ) : null; - GatewayMessage[] gatewayMessages = result != null ? [result] : []; + GatewayMessage[] gatewayMessages = result != null ? [result] : []; return ValueTask.FromResult(gatewayMessages); } } diff --git a/samples/esdb/Bookings.Payments/Registrations.cs b/samples/esdb/Bookings.Payments/Registrations.cs index d07cfbea5..5110a8ab6 100644 --- a/samples/esdb/Bookings.Payments/Registrations.cs +++ b/samples/esdb/Bookings.Payments/Registrations.cs @@ -3,9 +3,9 @@ using Bookings.Payments.Infrastructure; using Bookings.Payments.Integration; using Eventuous.Diagnostics.OpenTelemetry; -using Eventuous.EventStore; -using Eventuous.EventStore.Producers; -using Eventuous.EventStore.Subscriptions; +using Eventuous.KurrentDB; +using Eventuous.KurrentDB.Producers; +using Eventuous.KurrentDB.Subscriptions; using Eventuous.Projections.MongoDB; using OpenTelemetry.Metrics; using OpenTelemetry.Resources; @@ -15,15 +15,15 @@ namespace Bookings.Payments; public static class Registrations { public static void AddServices(this IServiceCollection services, IConfiguration configuration) { - services.AddEventStoreClient(configuration["EventStore:ConnectionString"]!); - services.AddEventStore(); + services.AddKurrentDBClient(configuration["EventStore:ConnectionString"]!); + services.AddEventStore(); services.AddCommandService(); services.AddSingleton(Mongo.ConfigureMongo(configuration)); services.AddCheckpointStore(); - services.AddProducer(); + services.AddProducer(); services - .AddGateway( + .AddGateway( "IntegrationSubscription", PaymentsGateway.Transform ); diff --git a/samples/esdb/Bookings/Bookings.csproj b/samples/esdb/Bookings/Bookings.csproj index b6cfec9c5..7403c67c2 100644 --- a/samples/esdb/Bookings/Bookings.csproj +++ b/samples/esdb/Bookings/Bookings.csproj @@ -25,7 +25,7 @@ - + diff --git a/samples/esdb/Bookings/Registrations.cs b/samples/esdb/Bookings/Registrations.cs index 1fcea4541..46d6cf369 100644 --- a/samples/esdb/Bookings/Registrations.cs +++ b/samples/esdb/Bookings/Registrations.cs @@ -7,8 +7,8 @@ using Bookings.Integration; using Eventuous; using Eventuous.Diagnostics.OpenTelemetry; -using Eventuous.EventStore; -using Eventuous.EventStore.Subscriptions; +using Eventuous.KurrentDB; +using Eventuous.KurrentDB.Subscriptions; using Eventuous.Projections.MongoDB; using Eventuous.Subscriptions.Registrations; using MongoDB.Driver.Core.Extensions.DiagnosticSources; @@ -21,70 +21,72 @@ namespace Bookings; public static class Registrations { - public static void AddEventuous(this IServiceCollection services, IConfiguration configuration) { - DefaultEventSerializer.SetDefaultSerializer( - new DefaultEventSerializer(new JsonSerializerOptions(JsonSerializerDefaults.Web).ConfigureForNodaTime(DateTimeZoneProviders.Tzdb)) - ); + extension(IServiceCollection services) { + public void AddEventuous(IConfiguration configuration) { + DefaultEventSerializer.SetDefaultSerializer( + new DefaultEventSerializer(new JsonSerializerOptions(JsonSerializerDefaults.Web).ConfigureForNodaTime(DateTimeZoneProviders.Tzdb)) + ); - services.AddEventStoreClient(configuration["EventStore:ConnectionString"]!); - services.AddEventStore(); - services.AddCommandService(); + services.AddKurrentDBClient(configuration["EventStore:ConnectionString"]!); + services.AddEventStore(); + services.AddCommandService(); - services.AddSingleton((_, _) => new(true)); - services.AddSingleton((from, currency) => new Money(from.Amount * 2, currency)); + services.AddSingleton((_, _) => new(true)); + services.AddSingleton((from, currency) => new Money(from.Amount * 2, currency)); - services.AddSingleton(Mongo.ConfigureMongo(configuration)); + services.AddSingleton(Mongo.ConfigureMongo(configuration)); - services.AddSubscription( - "BookingsProjections", - builder => builder - .UseCheckpointStore() - .AddEventHandler() - .AddEventHandler() - .WithPartitioningByStream(2) - ); - services.AddSingleton(); + services.AddSubscription( + "BookingsProjections", + builder => builder + .UseCheckpointStore() + .AddEventHandler() + .AddEventHandler() + .WithPartitioningByStream(2) + ); + services.AddSingleton(); - services.AddSubscription( - "PaymentIntegration", - builder => builder - .Configure(x => x.StreamName = PaymentsIntegrationHandler.Stream) - .AddEventHandler() - ); - } + services.AddSubscription( + "PaymentIntegration", + builder => builder + .Configure(x => x.StreamName = PaymentsIntegrationHandler.Stream) + .AddEventHandler() + ); + } - public static void AddTelemetry(this IServiceCollection services) { - var otelEnabled = Environment.GetEnvironmentVariable("OTEL_EXPORTER_OTLP_ENDPOINT") != null; + public void AddTelemetry() { + var otelEnabled = Environment.GetEnvironmentVariable("OTEL_EXPORTER_OTLP_ENDPOINT") != null; - services.AddOpenTelemetry() - .WithMetrics( - builder => { - builder - .SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("bookings")) - .AddAspNetCoreInstrumentation() - .AddEventuous() - .AddEventuousSubscriptions() - .AddPrometheusExporter(); - if (otelEnabled) builder.AddOtlpExporter(); - } - ); + services.AddOpenTelemetry() + .WithMetrics( + builder => { + builder + .SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("bookings")) + .AddAspNetCoreInstrumentation() + .AddEventuous() + .AddEventuousSubscriptions() + .AddPrometheusExporter(); + if (otelEnabled) builder.AddOtlpExporter(); + } + ); - services.AddOpenTelemetry() - .WithTracing( - builder => { - builder - .AddAspNetCoreInstrumentation() - .AddGrpcClientInstrumentation() - .AddEventuousTracing() - .AddSource(typeof(DiagnosticsActivityEventSubscriber).Assembly.GetName().Name!) - .SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("bookings")) - .SetSampler(new AlwaysOnSampler()); + services.AddOpenTelemetry() + .WithTracing( + builder => { + builder + .AddAspNetCoreInstrumentation() + .AddGrpcClientInstrumentation() + .AddEventuousTracing() + .AddSource(typeof(DiagnosticsActivityEventSubscriber).Assembly.GetName().Name!) + .SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("bookings")) + .SetSampler(new AlwaysOnSampler()); - if (otelEnabled) - builder.AddOtlpExporter(); - else - builder.AddZipkinExporter(); - } - ); + if (otelEnabled) + builder.AddOtlpExporter(); + else + builder.AddZipkinExporter(); + } + ); + } } } diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 8dee96a7c..b06e6ebd3 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -10,7 +10,7 @@ $(SrcRoot)\Core\src $(SrcRoot)\Core\test $(SrcRoot)\Diagnostics\src - $(SrcRoot)\EventStore\src + $(SrcRoot)\KurrentDB\src $(SrcRoot)\Extensions\src $(SrcRoot)\Shovel\src ..\..\src diff --git a/src/EventStore/src/Eventuous.EventStore/Eventuous.EventStore.csproj.DotSettings b/src/EventStore/src/Eventuous.EventStore/Eventuous.EventStore.csproj.DotSettings deleted file mode 100644 index 95cf33420..000000000 --- a/src/EventStore/src/Eventuous.EventStore/Eventuous.EventStore.csproj.DotSettings +++ /dev/null @@ -1,2 +0,0 @@ - - True \ No newline at end of file diff --git a/src/EventStore/src/Eventuous.EventStore/README.md b/src/EventStore/src/Eventuous.EventStore/README.md deleted file mode 100644 index 2d1d2a7e3..000000000 --- a/src/EventStore/src/Eventuous.EventStore/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# Eventuous EventStoreDB support - -This package adds support for [EventStoreDB](https://eventstore.com) to applications built with Eventuous. -It includes the following components: - -- `EsdbEventStore` - implementation of the `IEventStore` interface -- Different types of subscriptions (catch-up and persistent) -- Message producer \ No newline at end of file diff --git a/src/EventStore/src/Eventuous.EventStore/Subscriptions/Diagnostics/AllStreamSubscriptionMeasure.cs b/src/EventStore/src/Eventuous.EventStore/Subscriptions/Diagnostics/AllStreamSubscriptionMeasure.cs deleted file mode 100644 index 9ca3c8ddf..000000000 --- a/src/EventStore/src/Eventuous.EventStore/Subscriptions/Diagnostics/AllStreamSubscriptionMeasure.cs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (C) Eventuous HQ OÜ. All rights reserved -// Licensed under the Apache License, Version 2.0. - -namespace Eventuous.EventStore.Subscriptions.Diagnostics; - -class AllStreamSubscriptionMeasure(string subscriptionId, EventStoreClient eventStoreClient) - : BaseSubscriptionMeasure(subscriptionId, "$all", eventStoreClient) { - protected override IAsyncEnumerable Read(CancellationToken cancellationToken) - => EventStoreClient.ReadAllAsync(Direction.Backwards, Position.End, 1, cancellationToken: cancellationToken); - - protected override ulong GetLastPosition(ResolvedEvent resolvedEvent) => resolvedEvent.Event.Position.CommitPosition; -} diff --git a/src/Experimental/src/ElasticPlayground/CombinedStore.cs b/src/Experimental/src/ElasticPlayground/CombinedStore.cs index 3a43a1cf3..c3f4e82e7 100644 --- a/src/Experimental/src/ElasticPlayground/CombinedStore.cs +++ b/src/Experimental/src/ElasticPlayground/CombinedStore.cs @@ -1,8 +1,8 @@ -using EventStore.Client; using Eventuous.ElasticSearch.Store; -using Eventuous.EventStore; +using Eventuous.KurrentDB; using Eventuous.Sut.App; using Eventuous.Sut.Domain; +using KurrentDB.Client; using Nest; using static Eventuous.Sut.App.Commands; @@ -13,9 +13,9 @@ public class CombinedStore { readonly EsdbEventStore _esdbEventStore; readonly ElasticEventStore _elasticEventStore; - public CombinedStore(IElasticClient elasticClient, EventStoreClient eventStoreClient) { + public CombinedStore(IElasticClient elasticClient, KurrentDBClient kurrentDbClient) { _elasticEventStore = new(elasticClient); - _esdbEventStore = new(eventStoreClient); + _esdbEventStore = new(kurrentDbClient); _store = new(_esdbEventStore, _elasticEventStore); } diff --git a/src/Experimental/src/ElasticPlayground/ConnectorAndArchive.cs b/src/Experimental/src/ElasticPlayground/ConnectorAndArchive.cs index 1f989488f..7aa309573 100644 --- a/src/Experimental/src/ElasticPlayground/ConnectorAndArchive.cs +++ b/src/Experimental/src/ElasticPlayground/ConnectorAndArchive.cs @@ -1,8 +1,8 @@ -using EventStore.Client; using Eventuous.ElasticSearch.Store; -using Eventuous.EventStore; +using Eventuous.KurrentDB; using Eventuous.Sut.App; using Eventuous.Sut.Domain; +using KurrentDB.Client; using Nest; using static Eventuous.Sut.App.Commands; @@ -13,9 +13,9 @@ public class ConnectorAndArchive { readonly ElasticEventStore _elasticEventStore; readonly TieredEventStore _tieredStore; - public ConnectorAndArchive(IElasticClient elasticClient, EventStoreClient eventStoreClient) { + public ConnectorAndArchive(IElasticClient elasticClient, KurrentDBClient kurrentDbClient) { _elasticEventStore = new(elasticClient); - _esdbEventStore = new(eventStoreClient); + _esdbEventStore = new(kurrentDbClient); _tieredStore = new(_esdbEventStore, _elasticEventStore); } diff --git a/src/Experimental/src/ElasticPlayground/ElasticPlayground.csproj b/src/Experimental/src/ElasticPlayground/ElasticPlayground.csproj index 7b651f863..865d23d52 100644 --- a/src/Experimental/src/ElasticPlayground/ElasticPlayground.csproj +++ b/src/Experimental/src/ElasticPlayground/ElasticPlayground.csproj @@ -6,14 +6,14 @@ true - + - + diff --git a/src/Experimental/src/ElasticPlayground/OnlyArchive.cs b/src/Experimental/src/ElasticPlayground/OnlyArchive.cs index ddbbbb6e2..0f59ed9d0 100644 --- a/src/Experimental/src/ElasticPlayground/OnlyArchive.cs +++ b/src/Experimental/src/ElasticPlayground/OnlyArchive.cs @@ -1,8 +1,8 @@ -using EventStore.Client; using Eventuous.ElasticSearch.Store; -using Eventuous.EventStore; +using Eventuous.KurrentDB; using Eventuous.Sut.App; using Eventuous.Sut.Domain; +using KurrentDB.Client; using Nest; using static Eventuous.Sut.App.Commands; @@ -11,9 +11,9 @@ namespace ElasticPlayground; public class OnlyArchive { readonly TieredEventStore _tieredEventStore; - public OnlyArchive(IElasticClient elasticClient, EventStoreClient eventStoreClient) { + public OnlyArchive(IElasticClient elasticClient, KurrentDBClient kurrentDBClient) { var elasticEventStore = new ElasticEventStore(elasticClient); - var esdbEventStore = new EsdbEventStore(eventStoreClient); + var esdbEventStore = new EsdbEventStore(kurrentDBClient); _tieredEventStore = new(esdbEventStore, elasticEventStore); } diff --git a/src/Experimental/src/ElasticPlayground/Program.cs b/src/Experimental/src/ElasticPlayground/Program.cs index 2dd3d66d2..44fb7f498 100644 --- a/src/Experimental/src/ElasticPlayground/Program.cs +++ b/src/Experimental/src/ElasticPlayground/Program.cs @@ -1,9 +1,9 @@ using System.Text.Json; using ElasticPlayground; using Elasticsearch.Net; -using EventStore.Client; using Eventuous.ElasticSearch.Store; using Eventuous.Sut.Domain; +using KurrentDB.Client; using Nest; using NodaTime; using NodaTime.Serialization.SystemTextJson; @@ -24,8 +24,8 @@ await elasticClient.ConfigureIndex(); -var esdbSettings = EventStoreClientSettings.Create("esdb://localhost:2113?tls=false"); -var eventStoreClient = new EventStoreClient(esdbSettings); +var kurrentDBClientSettings = KurrentDBClientSettings.Create("esdb://localhost:2113?tls=false"); +var kurrentDBClient = new KurrentDBClient(kurrentDBClientSettings); DefaultEventSerializer.SetDefaultSerializer(new DefaultEventSerializer(options)); // var elasticOnly = new ElasticOnly(client); @@ -37,5 +37,5 @@ // var connectorAndArchive = new ConnectorAndArchive(elasticClient, eventStoreClient); // await connectorAndArchive.Execute(); -var connectorAndArchive = new OnlyArchive(elasticClient, eventStoreClient); +var connectorAndArchive = new OnlyArchive(elasticClient, kurrentDBClient); await connectorAndArchive.Execute(); diff --git a/src/EventStore/docker-compose.yml b/src/KurrentDB/docker-compose.yml similarity index 100% rename from src/EventStore/docker-compose.yml rename to src/KurrentDB/docker-compose.yml diff --git a/src/EventStore/src/Eventuous.EventStore/Constants.cs b/src/KurrentDB/src/Eventuous.KurrentDB/Constants.cs similarity index 89% rename from src/EventStore/src/Eventuous.EventStore/Constants.cs rename to src/KurrentDB/src/Eventuous.KurrentDB/Constants.cs index 39a365260..06eef81ad 100644 --- a/src/EventStore/src/Eventuous.EventStore/Constants.cs +++ b/src/KurrentDB/src/Eventuous.KurrentDB/Constants.cs @@ -1,7 +1,7 @@ // Copyright (C) Eventuous HQ OÜ. All rights reserved // Licensed under the Apache License, Version 2.0. -namespace Eventuous.EventStore; +namespace Eventuous.KurrentDB; internal static class AttrConstants { internal const string DynamicSerializationMessage = "Only works with AOT when using DefaultStaticEventSerializer"; diff --git a/src/EventStore/src/Eventuous.EventStore/Eventuous.EventStore.csproj b/src/KurrentDB/src/Eventuous.KurrentDB/Eventuous.KurrentDB.csproj similarity index 80% rename from src/EventStore/src/Eventuous.EventStore/Eventuous.EventStore.csproj rename to src/KurrentDB/src/Eventuous.KurrentDB/Eventuous.KurrentDB.csproj index 85ad48667..9bd4249e0 100644 --- a/src/EventStore/src/Eventuous.EventStore/Eventuous.EventStore.csproj +++ b/src/KurrentDB/src/Eventuous.KurrentDB/Eventuous.KurrentDB.csproj @@ -6,8 +6,7 @@ true - - + @@ -18,13 +17,10 @@ - + - - - Tools\TaskExtensions.cs diff --git a/src/EventStore/src/Eventuous.EventStore/EsdbEventStore.cs b/src/KurrentDB/src/Eventuous.KurrentDB/KurrentDBEventStore.cs similarity index 67% rename from src/EventStore/src/Eventuous.EventStore/EsdbEventStore.cs rename to src/KurrentDB/src/Eventuous.KurrentDB/KurrentDBEventStore.cs index 5004ad086..945b48c59 100644 --- a/src/EventStore/src/Eventuous.EventStore/EsdbEventStore.cs +++ b/src/KurrentDB/src/Eventuous.KurrentDB/KurrentDBEventStore.cs @@ -6,20 +6,17 @@ using System.Runtime.CompilerServices; using System.Runtime.Serialization; using Eventuous.Tools; +using Microsoft.Extensions.Logging.Abstractions; using static Eventuous.DeserializationResult; using static Eventuous.Diagnostics.PersistenceEventSource; -namespace Eventuous.EventStore; +namespace Eventuous.KurrentDB; /// /// EventStoreDB implementation of /// -public class EsdbEventStore : IEventStore { - readonly ILogger? _logger; - readonly EventStoreClient _client; - readonly IEventSerializer _serializer; - readonly IMetadataSerializer _metaSerializer; - +[Obsolete("Use KurrentDBEventStore instead")] +public class EsdbEventStore : KurrentDBEventStore { /// /// Initialize the event store with the given client /// @@ -28,15 +25,63 @@ public class EsdbEventStore : IEventStore { /// Optional metadata serializer. When not provided, the default serializer will be used. /// Optional logger public EsdbEventStore( - EventStoreClient client, - IEventSerializer? serializer = null, - IMetadataSerializer? metaSerializer = null, - ILogger? logger = null + KurrentDBClient client, + IEventSerializer? serializer = null, + IMetadataSerializer? metaSerializer = null, + ILogger? logger = null + ) : base( + client, + serializer, + metaSerializer, + logger + ) { } + + /// + /// Initialize the event store with the given client settings. Will create the client instance. + /// + /// Client settings to be used to create a new client instance + /// Optional event serializer. When not provided, the default serializer will be used. + /// Optional metadata serializer. When not provided, the default serializer will be used. + /// Optional logger + public EsdbEventStore( + KurrentDBClientSettings clientSettings, + IEventSerializer? serializer = null, + IMetadataSerializer? metaSerializer = null, + ILogger? logger = null + ) : base( + clientSettings, + serializer, + metaSerializer, + logger + ) { } +} + +/// +/// EventStoreDB implementation of +/// +public partial class KurrentDBEventStore : IEventStore { + readonly ILogger _logger; + readonly KurrentDBClient _client; + readonly IEventSerializer _serializer; + readonly IMetadataSerializer _metaSerializer; + + /// + /// Initialize the event store with the given client + /// + /// EventStoreDB client instance + /// Optional event serializer. When not provided, the default serializer will be used. + /// Optional metadata serializer. When not provided, the default serializer will be used. + /// Optional logger + public KurrentDBEventStore( + KurrentDBClient client, + IEventSerializer? serializer = null, + IMetadataSerializer? metaSerializer = null, + ILogger? logger = null ) { - _logger = logger; _client = Ensure.NotNull(client); _serializer = serializer ?? DefaultEventSerializer.Instance; _metaSerializer = metaSerializer ?? DefaultMetadataSerializer.Instance; + _logger = logger ?? NullLogger.Instance; } /// @@ -46,12 +91,12 @@ public EsdbEventStore( /// Optional event serializer. When not provided, the default serializer will be used. /// Optional metadata serializer. When not provided, the default serializer will be used. /// Optional logger - public EsdbEventStore( - EventStoreClientSettings clientSettings, - IEventSerializer? serializer = null, - IMetadataSerializer? metaSerializer = null, - ILogger? logger = null - ) : this(new EventStoreClient(Ensure.NotNull(clientSettings)), serializer, metaSerializer, logger) { } + public KurrentDBEventStore( + KurrentDBClientSettings clientSettings, + IEventSerializer? serializer = null, + IMetadataSerializer? metaSerializer = null, + ILogger? logger = null + ) : this(new KurrentDBClient(Ensure.NotNull(clientSettings)), serializer, metaSerializer, logger) { } /// public async Task StreamExists(StreamName stream, CancellationToken cancellationToken = default) { @@ -76,19 +121,14 @@ public Task AppendEvents( var proposedEvents = events.Select(ToEventData); var deadline = TimeSpan.FromSeconds(60); - var resultTask = expectedVersion == ExpectedStreamVersion.NoStream - ? _client.AppendToStreamAsync(stream, StreamState.NoStream, proposedEvents, deadline: deadline, cancellationToken: cancellationToken) - : AnyOrNot( - expectedVersion, - () => _client.AppendToStreamAsync(stream, StreamState.Any, proposedEvents, deadline: deadline, cancellationToken: cancellationToken), - () => _client.AppendToStreamAsync(stream, expectedVersion.AsStreamRevision(), proposedEvents, deadline: deadline, cancellationToken: cancellationToken) - ); + + var resultTask = _client.AppendToStreamAsync(stream, ToStreamState(expectedVersion), proposedEvents, deadline: deadline, cancellationToken: cancellationToken); return TryExecute( async () => { var result = await resultTask.NoContext(); - return new AppendEventsResult(result.LogPosition.CommitPosition, result.NextExpectedStreamRevision.ToInt64()); + return new AppendEventsResult(result.LogPosition.CommitPosition, result.NextExpectedStreamState.ToInt64()); }, stream, true, @@ -99,6 +139,7 @@ public Task AppendEvents( return new AppendToStreamException(s, ex); } ); + [RequiresDynamicCode("Calls Eventuous.IEventSerializer.SerializeEvent(Object)")] [RequiresUnreferencedCode("Calls Eventuous.IEventSerializer.SerializeEvent(Object)")] EventData ToEventData(NewStreamEvent streamEvent) { @@ -123,8 +164,7 @@ public async Task ReadEvents(StreamName stream, StreamReadPositio try { return await TryExecute( async () => { - var resolvedEvents = await read.ToArrayAsync(cancellationToken).NoContext(); - bool x = true; + var resolvedEvents = await read.ToArrayAsync(cancellationToken).NoContext(); return ToStreamEvents(resolvedEvents); }, @@ -186,11 +226,7 @@ CancellationToken cancellationToken var meta = new StreamMetadata(truncateBefore: truncatePosition.AsStreamPosition()); return TryExecute( - () => AnyOrNot( - expectedVersion, - () => _client.SetStreamMetadataAsync(stream, StreamState.Any, meta, cancellationToken: cancellationToken), - () => _client.SetStreamMetadataAsync(stream, expectedVersion.AsStreamRevision(), meta, cancellationToken: cancellationToken) - ), + () => _client.SetStreamMetadataAsync(stream, ToStreamState(expectedVersion), meta, cancellationToken: cancellationToken), stream, expectedVersion.ExistingStream, () => new("Unable to truncate stream {Stream} at {Position}", stream, truncatePosition), @@ -201,11 +237,7 @@ CancellationToken cancellationToken /// public Task DeleteStream(StreamName stream, ExpectedStreamVersion expectedVersion, CancellationToken cancellationToken = default) => TryExecute( - () => AnyOrNot( - expectedVersion, - () => _client.DeleteAsync(stream, StreamState.Any, cancellationToken: cancellationToken), - () => _client.DeleteAsync(stream, expectedVersion.AsStreamRevision(), cancellationToken: cancellationToken) - ), + () => _client.DeleteAsync(stream, ToStreamState(expectedVersion), cancellationToken: cancellationToken), stream, expectedVersion.ExistingStream, () => new("Unable to delete stream {Stream}", stream), @@ -223,7 +255,7 @@ Func getException return await func().NoContext(); } catch (StreamNotFoundException) { if (failIfNotFound) { - _logger?.LogWarning("Stream {Stream} not found", stream); + LogStreamStreamNotFound(stream); } throw new StreamNotFound(stream); @@ -231,7 +263,7 @@ Func getException var (message, args) = getError(); // ReSharper disable once TemplateIsNotCompileTimeConstantProblem #pragma warning disable CA2254 - _logger?.LogWarning(ex, message, args); + _logger.LogWarning(ex, message, args); #pragma warning restore CA2254 throw getException(stream, ex); @@ -239,8 +271,12 @@ Func getException } [MethodImpl(MethodImplOptions.AggressiveInlining)] - static Task AnyOrNot(ExpectedStreamVersion version, Func> whenAny, Func> otherwise) - => version == ExpectedStreamVersion.Any ? whenAny() : otherwise(); + static StreamState ToStreamState(ExpectedStreamVersion version) + => version == ExpectedStreamVersion.NoStream + ? StreamState.NoStream + : version == ExpectedStreamVersion.Any + ? StreamState.Any + : StreamState.StreamRevision((ulong)version.Value); [MethodImpl(MethodImplOptions.AggressiveInlining)] [RequiresDynamicCode(AttrConstants.DynamicSerializationMessage)] @@ -258,7 +294,8 @@ static Task AnyOrNot(ExpectedStreamVersion version, Func> whenAny, _ => throw new SerializationException("Unknown deserialization result") }; - StreamEvent? HandleFailure(FailedToDeserialize failed) => resolvedEvent.Event.EventType.StartsWith('$') ? null : throw new SerializationException($"Can't deserialize {resolvedEvent.Event.EventType}: {failed.Error}"); + StreamEvent? HandleFailure(FailedToDeserialize failed) + => resolvedEvent.Event.EventType.StartsWith('$') ? null : throw new SerializationException($"Can't deserialize {resolvedEvent.Event.EventType}: {failed.Error}"); Metadata? DeserializeMetadata() { var meta = resolvedEvent.Event.Metadata.Span; @@ -266,12 +303,7 @@ static Task AnyOrNot(ExpectedStreamVersion version, Func> whenAny, try { return meta.Length == 0 ? null : _metaSerializer.Deserialize(meta); } catch (MetadataDeserializationException e) { - _logger?.LogWarning( - e, - "Failed to deserialize metadata at {Stream}:{Position}", - resolvedEvent.Event.EventStreamId, - resolvedEvent.Event.EventNumber - ); + LogFailedToDeserializeMetadataAtStreamPosition(resolvedEvent.Event.EventStreamId, resolvedEvent.Event.EventNumber, e); return null; } @@ -297,4 +329,10 @@ StreamEvent[] ToStreamEvents(ResolvedEvent[] resolvedEvents) .ToArray(); record ErrorInfo(string Message, params object[] Args); + + [LoggerMessage(LogLevel.Warning, "Stream {stream} not found")] + partial void LogStreamStreamNotFound(string stream); + + [LoggerMessage(LogLevel.Warning, "Failed to deserialize metadata at {stream}:{position}")] + partial void LogFailedToDeserializeMetadataAtStreamPosition(string stream, StreamPosition position, Exception ex); } diff --git a/src/EventStore/src/Eventuous.EventStore/Producers/EventStoreProduceOptions.cs b/src/KurrentDB/src/Eventuous.KurrentDB/Producers/KurrentDbProduceOptions.cs similarity index 84% rename from src/EventStore/src/Eventuous.EventStore/Producers/EventStoreProduceOptions.cs rename to src/KurrentDB/src/Eventuous.KurrentDB/Producers/KurrentDbProduceOptions.cs index 199a91b4f..4cad2f90b 100644 --- a/src/EventStore/src/Eventuous.EventStore/Producers/EventStoreProduceOptions.cs +++ b/src/KurrentDB/src/Eventuous.KurrentDB/Producers/KurrentDbProduceOptions.cs @@ -1,13 +1,13 @@ // Copyright (C) Eventuous HQ OÜ. All rights reserved // Licensed under the Apache License, Version 2.0. -namespace Eventuous.EventStore.Producers; +namespace Eventuous.KurrentDB.Producers; /// /// Event producing options /// [PublicAPI] -public record EventStoreProduceOptions { +public record KurrentDbProduceOptions { /// /// User credentials /// @@ -31,5 +31,5 @@ public record EventStoreProduceOptions { /// /// Default set of options /// - public static EventStoreProduceOptions Default { get; } = new(); + public static KurrentDbProduceOptions Default { get; } = new(); } \ No newline at end of file diff --git a/src/EventStore/src/Eventuous.EventStore/Producers/EventStoreProducer.cs b/src/KurrentDB/src/Eventuous.KurrentDB/Producers/KurrentDbProducer.cs similarity index 77% rename from src/EventStore/src/Eventuous.EventStore/Producers/EventStoreProducer.cs rename to src/KurrentDB/src/Eventuous.KurrentDB/Producers/KurrentDbProducer.cs index 2fcb5ab40..b8162ffd1 100644 --- a/src/EventStore/src/Eventuous.EventStore/Producers/EventStoreProducer.cs +++ b/src/KurrentDB/src/Eventuous.KurrentDB/Producers/KurrentDbProducer.cs @@ -5,26 +5,26 @@ using Eventuous.Producers.Diagnostics; using Eventuous.Tools; -namespace Eventuous.EventStore.Producers; +namespace Eventuous.KurrentDB.Producers; /// /// Producer for EventStoreDB /// [PublicAPI] -public class EventStoreProducer : BaseProducer { - readonly EventStoreClient _client; +public class KurrentDbProducer : BaseProducer { + readonly KurrentDBClient _client; readonly IEventSerializer _serializer; readonly IMetadataSerializer _metaSerializer; /// /// Create a new EventStoreDB producer instance /// - /// EventStoreDB gRPC client + /// EventStoreDB gRPC client /// Optional: event serializer instance /// Optional: metadata serializer instance - public EventStoreProducer(EventStoreClient eventStoreClient, IEventSerializer? serializer = null, IMetadataSerializer? metaSerializer = null) + public KurrentDbProducer(KurrentDBClient client, IEventSerializer? serializer = null, IMetadataSerializer? metaSerializer = null) : base(TracingOptions) { - _client = Ensure.NotNull(eventStoreClient); + _client = Ensure.NotNull(client); _serializer = serializer ?? DefaultEventSerializer.Instance; _metaSerializer = metaSerializer ?? DefaultMetadataSerializer.Instance; } @@ -35,12 +35,12 @@ public EventStoreProducer(EventStoreClient eventStoreClient, IEventSerializer? s /// EventStoreDB gRPC client settings /// Optional: event serializer instance /// Optional: metadata serializer instance - public EventStoreProducer(EventStoreClientSettings clientSettings, IEventSerializer? serializer = null, IMetadataSerializer? metaSerializer = null) - : this(new EventStoreClient(Ensure.NotNull(clientSettings)), serializer, metaSerializer) { } + public KurrentDbProducer(KurrentDBClientSettings clientSettings, IEventSerializer? serializer = null, IMetadataSerializer? metaSerializer = null) + : this(new KurrentDBClient(Ensure.NotNull(clientSettings)), serializer, metaSerializer) { } static readonly ProducerTracingOptions TracingOptions = new() { DestinationKind = "stream", - MessagingSystem = "eventstoredb", + MessagingSystem = "kurrentdb", ProduceOperation = "append" }; @@ -56,10 +56,10 @@ public EventStoreProducer(EventStoreClientSettings clientSettings, IEventSeriali protected override async Task ProduceMessages( StreamName stream, IEnumerable messages, - EventStoreProduceOptions? produceOptions, + KurrentDbProduceOptions? produceOptions, CancellationToken cancellationToken = default ) { - var options = produceOptions ?? EventStoreProduceOptions.Default; + var options = produceOptions ?? KurrentDbProduceOptions.Default; foreach (var chunk in Ensure.NotNull(messages).Chunks(options.MaxAppendEventsCount)) { var chunkMessages = chunk.ToArray(); @@ -79,10 +79,10 @@ await _client.AppendToStreamAsync( ) .NoContext(); - await chunkMessages.Select(x => x.Ack()).WhenAll().NoContext(); + await chunkMessages.Select(x => x.Ack()).WhenAll().NoContext(); } catch (Exception e) { await chunkMessages - .Select(x => x.Nack("Unable to produce to EventStoreDB", e)) + .Select(x => x.Nack("Unable to produce to EventStoreDB", e)) .WhenAll() .NoContext(); } diff --git a/src/KurrentDB/src/Eventuous.KurrentDB/README.md b/src/KurrentDB/src/Eventuous.KurrentDB/README.md new file mode 100644 index 000000000..f96881767 --- /dev/null +++ b/src/KurrentDB/src/Eventuous.KurrentDB/README.md @@ -0,0 +1,8 @@ +# Eventuous KurrentDB support + +This package adds support for [KurrentDB](https://kurrent.io) to applications built with Eventuous. +It includes the following components: + +- `KurrentDBEventStore` - implementation of the `IEventStore` interface +- Different types of subscriptions (catch-up and persistent) +- Message producer \ No newline at end of file diff --git a/src/EventStore/src/Eventuous.EventStore/StreamRevisionExtensions.cs b/src/KurrentDB/src/Eventuous.KurrentDB/StreamRevisionExtensions.cs similarity index 78% rename from src/EventStore/src/Eventuous.EventStore/StreamRevisionExtensions.cs rename to src/KurrentDB/src/Eventuous.KurrentDB/StreamRevisionExtensions.cs index f40565913..6c6bac2c6 100644 --- a/src/EventStore/src/Eventuous.EventStore/StreamRevisionExtensions.cs +++ b/src/KurrentDB/src/Eventuous.KurrentDB/StreamRevisionExtensions.cs @@ -1,18 +1,18 @@ -namespace Eventuous.EventStore; +namespace Eventuous.KurrentDB; /// /// Internal conversions between Event Store and Eventuous types for stream positions and revisions /// public static class StreamRevisionExtensions { /// - /// Converts to + /// Converts to /// /// Stream version /// - public static StreamRevision AsStreamRevision(this ExpectedStreamVersion version) => StreamRevision.FromInt64(version.Value); + public static StreamState AsStreamRevision(this ExpectedStreamVersion version) => StreamState.StreamRevision((ulong)version.Value); /// - /// Converts to + /// Converts to /// /// Position for stream truncation /// diff --git a/src/EventStore/src/Eventuous.EventStore/Subscriptions/AllPersistentSubscription.cs b/src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/AllPersistentSubscription.cs similarity index 80% rename from src/EventStore/src/Eventuous.EventStore/Subscriptions/AllPersistentSubscription.cs rename to src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/AllPersistentSubscription.cs index afa47063b..9bbd66a88 100644 --- a/src/EventStore/src/Eventuous.EventStore/Subscriptions/AllPersistentSubscription.cs +++ b/src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/AllPersistentSubscription.cs @@ -1,11 +1,11 @@ // Copyright (C) Eventuous HQ OÜ. All rights reserved // Licensed under the Apache License, Version 2.0. -using Eventuous.EventStore.Subscriptions.Diagnostics; +using Eventuous.KurrentDB.Subscriptions.Diagnostics; using Eventuous.Subscriptions.Diagnostics; using Eventuous.Subscriptions.Filters; -namespace Eventuous.EventStore.Subscriptions; +namespace Eventuous.KurrentDB.Subscriptions; /// /// Persistent subscription for EventStoreDB, for $all stream @@ -14,45 +14,45 @@ public class AllPersistentSubscription : PersistentSubscriptionBase /// Persistent subscription for EventStoreDB, for $all stream /// - /// EventStoreDB client instance + /// EventStoreDB client instance /// Persistent subscription options /// Consume pipe, usually provided by the builder /// Optional logger factory /// Event payload serializer /// Metadata serializer public AllPersistentSubscription( - EventStoreClient eventStoreClient, + KurrentDBClient client, AllPersistentSubscriptionOptions options, ConsumePipe consumePipe, ILoggerFactory? loggerFactory = null, IEventSerializer? eventSerializer = null, IMetadataSerializer? metaSerializer = null ) - : base(eventStoreClient, options, consumePipe, loggerFactory, eventSerializer, metaSerializer) { } + : base(client, options, consumePipe, loggerFactory, eventSerializer, metaSerializer) { } /// /// Persistent subscription for EventStoreDB, for $all stream /// - /// EventStoreDB persistent subscription client instance + /// EventStoreDB persistent subscription client instance /// Persistent subscription options /// Consume pipe, usually provided by the builder /// Optional logger factory /// Event payload serializer /// Metadata serializer public AllPersistentSubscription( - EventStorePersistentSubscriptionsClient eventStoreClient, - AllPersistentSubscriptionOptions options, - ConsumePipe consumePipe, - ILoggerFactory? loggerFactory = null, - IEventSerializer? eventSerializer = null, - IMetadataSerializer? metaSerializer = null + KurrentDBPersistentSubscriptionsClient client, + AllPersistentSubscriptionOptions options, + ConsumePipe consumePipe, + ILoggerFactory? loggerFactory = null, + IEventSerializer? eventSerializer = null, + IMetadataSerializer? metaSerializer = null ) - : base(eventStoreClient, options, consumePipe, loggerFactory, eventSerializer, metaSerializer) { } + : base(client, options, consumePipe, loggerFactory, eventSerializer, metaSerializer) { } /// /// Creates EventStoreDB persistent subscription service for a given stream /// - /// EventStoreDB gRPC client instance + /// EventStoreDB gRPC client instance /// Subscription ID /// Consume pipe /// Optional: event serializer instance @@ -60,7 +60,7 @@ public AllPersistentSubscription( /// Optional: subscription filter /// Optional: logger factory public AllPersistentSubscription( - EventStoreClient eventStoreClient, + KurrentDBClient client, string subscriptionId, ConsumePipe consumerPipe, IEventSerializer? eventSerializer = null, @@ -69,7 +69,7 @@ public AllPersistentSubscription( ILoggerFactory? loggerFactory = null ) : this( - eventStoreClient, + client, new() { SubscriptionId = subscriptionId, EventFilter = eventFilter @@ -124,5 +124,5 @@ CancellationToken cance /// Returns a measure callback for the subscription /// /// - public GetSubscriptionEndOfStream GetMeasure() => new AllStreamSubscriptionMeasure(Options.SubscriptionId, EventStoreClient).GetEndOfStream; + public GetSubscriptionEndOfStream GetMeasure() => new AllStreamSubscriptionMeasure(Options.SubscriptionId, Client).GetEndOfStream; } diff --git a/src/EventStore/src/Eventuous.EventStore/Subscriptions/AllStreamSubscription.cs b/src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/AllStreamSubscription.cs similarity index 86% rename from src/EventStore/src/Eventuous.EventStore/Subscriptions/AllStreamSubscription.cs rename to src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/AllStreamSubscription.cs index 6b2de34ee..3d5ceead6 100644 --- a/src/EventStore/src/Eventuous.EventStore/Subscriptions/AllStreamSubscription.cs +++ b/src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/AllStreamSubscription.cs @@ -1,7 +1,7 @@ // Copyright (C) Eventuous HQ OÜ. All rights reserved // Licensed under the Apache License, Version 2.0. -using Eventuous.EventStore.Subscriptions.Diagnostics; +using Eventuous.KurrentDB.Subscriptions.Diagnostics; using Eventuous.Subscriptions.Checkpoints; using Eventuous.Subscriptions.Context; using Eventuous.Subscriptions.Diagnostics; @@ -10,7 +10,7 @@ // ReSharper disable ConvertClosureToMethodGroup -namespace Eventuous.EventStore.Subscriptions; +namespace Eventuous.KurrentDB.Subscriptions; /// /// Catch-up subscription for EventStoreDB, using the $all global stream @@ -20,7 +20,7 @@ public class AllStreamSubscription : EventStoreCatchUpSubscriptionBase /// Creates EventStoreDB catch-up subscription service for $all /// - /// EventStoreDB gRPC client instance + /// EventStoreDB gRPC client instance /// Subscription ID /// Checkpoint store instance /// @@ -29,7 +29,7 @@ public class AllStreamSubscription : EventStoreCatchUpSubscriptionBaseOptional: server-side event filter /// public AllStreamSubscription( - EventStoreClient eventStoreClient, + KurrentDBClient client, string subscriptionId, ICheckpointStore checkpointStore, ConsumePipe consumePipe, @@ -38,7 +38,7 @@ public AllStreamSubscription( IEventFilter? eventFilter = null, ILoggerFactory? loggerFactory = null ) : this( - eventStoreClient, + client, new() { SubscriptionId = subscriptionId, EventFilter = eventFilter @@ -53,7 +53,7 @@ public AllStreamSubscription( /// /// Creates EventStoreDB catch-up subscription service for $all /// - /// + /// /// /// Checkpoint store instance /// @@ -61,14 +61,14 @@ public AllStreamSubscription( /// Event serializer /// Metadata serializer public AllStreamSubscription( - EventStoreClient eventStoreClient, + KurrentDBClient client, AllStreamSubscriptionOptions options, ICheckpointStore checkpointStore, ConsumePipe consumePipe, ILoggerFactory? loggerFactory = null, IEventSerializer? eventSerializer = null, IMetadataSerializer? metaSerializer = null - ) : base(eventStoreClient, options, checkpointStore, consumePipe, SubscriptionKind.All, loggerFactory, eventSerializer, metaSerializer) { } + ) : base(client, options, checkpointStore, consumePipe, SubscriptionKind.All, loggerFactory, eventSerializer, metaSerializer) { } /// /// Starts the subscription @@ -86,7 +86,7 @@ protected override async ValueTask Subscribe(CancellationToken cancellationToken var fromAll = position == null ? FromAll.Start : FromAll.After(new(position.Value, position.Value)); - Subscription = await EventStoreClient.SubscribeToAllAsync( + Subscription = await Client.SubscribeToAllAsync( fromAll, (_, @event, ct) => HandleEvent(@event, ct), Options.ResolveLinkTos, @@ -102,7 +102,7 @@ protected override async ValueTask Subscribe(CancellationToken cancellationToken Task HandleEvent(ResolvedEvent re, CancellationToken ct) => HandleInternal(CreateContext(re, ct)).AsTask(); - void HandleDrop(global::EventStore.Client.StreamSubscription _, SubscriptionDroppedReason reason, Exception? ex) + void HandleDrop(global::KurrentDB.Client.StreamSubscription _, SubscriptionDroppedReason reason, Exception? ex) => Dropped(EsdbMappings.AsDropReason(reason), ex); } @@ -138,5 +138,5 @@ MessageConsumeContext CreateContext(ResolvedEvent re, CancellationToken cancella /// Returns a measure delegate for the subscription /// /// - public GetSubscriptionEndOfStream GetMeasure() => new AllStreamSubscriptionMeasure(Options.SubscriptionId, EventStoreClient).GetEndOfStream; + public GetSubscriptionEndOfStream GetMeasure() => new AllStreamSubscriptionMeasure(Options.SubscriptionId, Client).GetEndOfStream; } diff --git a/src/EventStore/src/Eventuous.EventStore/Subscriptions/ConsumePipeExtensions.cs b/src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/ConsumePipeExtensions.cs similarity index 92% rename from src/EventStore/src/Eventuous.EventStore/Subscriptions/ConsumePipeExtensions.cs rename to src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/ConsumePipeExtensions.cs index df107d205..c064e0fdc 100644 --- a/src/EventStore/src/Eventuous.EventStore/Subscriptions/ConsumePipeExtensions.cs +++ b/src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/ConsumePipeExtensions.cs @@ -3,7 +3,7 @@ using Eventuous.Subscriptions.Filters; -namespace Eventuous.EventStore.Subscriptions; +namespace Eventuous.KurrentDB.Subscriptions; /// /// Extensions for diff --git a/src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/Diagnostics/AllStreamSubscriptionMeasure.cs b/src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/Diagnostics/AllStreamSubscriptionMeasure.cs new file mode 100644 index 000000000..a80fb8436 --- /dev/null +++ b/src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/Diagnostics/AllStreamSubscriptionMeasure.cs @@ -0,0 +1,12 @@ +// Copyright (C) Eventuous HQ OÜ. All rights reserved +// Licensed under the Apache License, Version 2.0. + +namespace Eventuous.KurrentDB.Subscriptions.Diagnostics; + +class AllStreamSubscriptionMeasure(string subscriptionId, KurrentDBClient client) + : BaseSubscriptionMeasure(subscriptionId, "$all", client) { + protected override IAsyncEnumerable Read(CancellationToken cancellationToken) + => Client.ReadAllAsync(Direction.Backwards, Position.End, 1, cancellationToken: cancellationToken); + + protected override ulong GetLastPosition(ResolvedEvent resolvedEvent) => resolvedEvent.Event.Position.CommitPosition; +} diff --git a/src/EventStore/src/Eventuous.EventStore/Subscriptions/Diagnostics/BaseSubscriptionMeasure.cs b/src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/Diagnostics/BaseSubscriptionMeasure.cs similarity index 87% rename from src/EventStore/src/Eventuous.EventStore/Subscriptions/Diagnostics/BaseSubscriptionMeasure.cs rename to src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/Diagnostics/BaseSubscriptionMeasure.cs index eaf0ffc2d..e260e8824 100644 --- a/src/EventStore/src/Eventuous.EventStore/Subscriptions/Diagnostics/BaseSubscriptionMeasure.cs +++ b/src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/Diagnostics/BaseSubscriptionMeasure.cs @@ -6,10 +6,10 @@ using Eventuous.Subscriptions.Diagnostics; using Eventuous.Tools; -namespace Eventuous.EventStore.Subscriptions.Diagnostics; +namespace Eventuous.KurrentDB.Subscriptions.Diagnostics; -abstract class BaseSubscriptionMeasure(string subscriptionId, string streamName, EventStoreClient eventStoreClient) { - protected readonly EventStoreClient EventStoreClient = eventStoreClient; +abstract class BaseSubscriptionMeasure(string subscriptionId, string streamName, KurrentDBClient client) { + protected readonly KurrentDBClient Client = client; protected abstract IAsyncEnumerable Read(CancellationToken cancellationToken); diff --git a/src/EventStore/src/Eventuous.EventStore/Subscriptions/Diagnostics/StreamSubscriptionMeasure.cs b/src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/Diagnostics/StreamSubscriptionMeasure.cs similarity index 54% rename from src/EventStore/src/Eventuous.EventStore/Subscriptions/Diagnostics/StreamSubscriptionMeasure.cs rename to src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/Diagnostics/StreamSubscriptionMeasure.cs index d04ab237f..e0ce08017 100644 --- a/src/EventStore/src/Eventuous.EventStore/Subscriptions/Diagnostics/StreamSubscriptionMeasure.cs +++ b/src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/Diagnostics/StreamSubscriptionMeasure.cs @@ -1,12 +1,12 @@ // Copyright (C) Eventuous HQ OÜ. All rights reserved // Licensed under the Apache License, Version 2.0. -namespace Eventuous.EventStore.Subscriptions.Diagnostics; +namespace Eventuous.KurrentDB.Subscriptions.Diagnostics; -class StreamSubscriptionMeasure(string subscriptionId, StreamName streamName, EventStoreClient eventStoreClient) - : BaseSubscriptionMeasure(subscriptionId, streamName, eventStoreClient) { +class StreamSubscriptionMeasure(string subscriptionId, StreamName streamName, KurrentDBClient client) + : BaseSubscriptionMeasure(subscriptionId, streamName, client) { protected override IAsyncEnumerable Read(CancellationToken cancellationToken) - => EventStoreClient.ReadStreamAsync(Direction.Backwards, streamName, StreamPosition.End, 1, cancellationToken: cancellationToken); + => Client.ReadStreamAsync(Direction.Backwards, streamName, StreamPosition.End, 1, cancellationToken: cancellationToken); protected override ulong GetLastPosition(ResolvedEvent resolvedEvent) => resolvedEvent.Event.EventNumber; } diff --git a/src/EventStore/src/Eventuous.EventStore/Subscriptions/EsdbMappings.cs b/src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/EsdbMappings.cs similarity index 92% rename from src/EventStore/src/Eventuous.EventStore/Subscriptions/EsdbMappings.cs rename to src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/EsdbMappings.cs index 41a2c0861..067b90a6d 100644 --- a/src/EventStore/src/Eventuous.EventStore/Subscriptions/EsdbMappings.cs +++ b/src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/EsdbMappings.cs @@ -1,7 +1,7 @@ // Copyright (C) Eventuous HQ OÜ. All rights reserved // Licensed under the Apache License, Version 2.0. -namespace Eventuous.EventStore.Subscriptions; +namespace Eventuous.KurrentDB.Subscriptions; static class EsdbMappings { public static DropReason AsDropReason(SubscriptionDroppedReason reason) diff --git a/src/EventStore/src/Eventuous.EventStore/Subscriptions/EventStoreCatchUpSubscriptionBase.cs b/src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/EventStoreCatchUpSubscriptionBase.cs similarity index 85% rename from src/EventStore/src/Eventuous.EventStore/Subscriptions/EventStoreCatchUpSubscriptionBase.cs rename to src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/EventStoreCatchUpSubscriptionBase.cs index 88de58249..7e6cf1ea8 100644 --- a/src/EventStore/src/Eventuous.EventStore/Subscriptions/EventStoreCatchUpSubscriptionBase.cs +++ b/src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/EventStoreCatchUpSubscriptionBase.cs @@ -4,7 +4,7 @@ using Eventuous.Subscriptions.Checkpoints; using Eventuous.Subscriptions.Filters; -namespace Eventuous.EventStore.Subscriptions; +namespace Eventuous.KurrentDB.Subscriptions; /// /// Base class for EventStoreDB catch-up subscriptions @@ -15,7 +15,7 @@ public abstract class EventStoreCatchUpSubscriptionBase : EventSubscriptionWi /// /// Catch-up subscription base class constructor /// - /// EventStoreDB client instance + /// EventStoreDB client instance /// Subscription options /// Checkpoint store /// Consume pipe, usually provided by the subscription builder @@ -24,7 +24,7 @@ public abstract class EventStoreCatchUpSubscriptionBase : EventSubscriptionWi /// Optional: event serializer instance /// Optional: metadata serializer instance protected EventStoreCatchUpSubscriptionBase( - EventStoreClient eventStoreClient, + KurrentDBClient client, T options, ICheckpointStore checkpointStore, ConsumePipe consumePipe, @@ -34,12 +34,12 @@ protected EventStoreCatchUpSubscriptionBase( IMetadataSerializer? metaSerializer ) : base(Ensure.NotNull(options), checkpointStore, consumePipe, options.ConcurrencyLimit, kind, loggerFactory, eventSerializer, metaSerializer) - => EventStoreClient = eventStoreClient; + => Client = client; /// /// EventStoreDB client instance /// - protected EventStoreClient EventStoreClient { get; } + protected KurrentDBClient Client { get; } /// /// Stops the subscription @@ -58,5 +58,5 @@ protected override async ValueTask Unsubscribe(CancellationToken cancellationTok /// /// Underlying EventStoreDB subscription /// - protected global::EventStore.Client.StreamSubscription? Subscription { get; set; } + protected global::KurrentDB.Client.StreamSubscription? Subscription { get; set; } } diff --git a/src/EventStore/src/Eventuous.EventStore/Subscriptions/EventStoreExtensions.cs b/src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/KurrentDbExtensions.cs similarity index 58% rename from src/EventStore/src/Eventuous.EventStore/Subscriptions/EventStoreExtensions.cs rename to src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/KurrentDbExtensions.cs index f4f1b1a26..c062f18a7 100644 --- a/src/EventStore/src/Eventuous.EventStore/Subscriptions/EventStoreExtensions.cs +++ b/src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/KurrentDbExtensions.cs @@ -3,17 +3,17 @@ using System.Reflection; -namespace Eventuous.EventStore.Subscriptions; +namespace Eventuous.KurrentDB.Subscriptions; -static class EventStoreExtensions { - public static EventStoreClientSettings GetSettings(this EventStoreClientBase client) { - var prop = typeof(EventStoreClientBase).GetProperty("Settings", BindingFlags.NonPublic | BindingFlags.Instance); +static class KurrentDbExtensions { + public static KurrentDBClientSettings GetSettings(this KurrentDBClientBase client) { + var prop = typeof(KurrentDBClientBase).GetProperty("Settings", BindingFlags.NonPublic | BindingFlags.Instance); var getter = prop!.GetGetMethod(true); - return (EventStoreClientSettings) getter!.Invoke(client, null)!; + return (KurrentDBClientSettings) getter!.Invoke(client, null)!; } - public static EventStoreClientSettings Copy(this EventStoreClientSettings settings) + public static KurrentDBClientSettings Copy(this KurrentDBClientSettings settings) => new() { Interceptors = settings.Interceptors, ChannelCredentials = settings.ChannelCredentials, diff --git a/src/EventStore/src/Eventuous.EventStore/Subscriptions/Options/AllPersistentSubscriptionOptions.cs b/src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/Options/AllPersistentSubscriptionOptions.cs similarity index 92% rename from src/EventStore/src/Eventuous.EventStore/Subscriptions/Options/AllPersistentSubscriptionOptions.cs rename to src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/Options/AllPersistentSubscriptionOptions.cs index bbb42b2fd..71151b97d 100644 --- a/src/EventStore/src/Eventuous.EventStore/Subscriptions/Options/AllPersistentSubscriptionOptions.cs +++ b/src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/Options/AllPersistentSubscriptionOptions.cs @@ -1,7 +1,7 @@ // Copyright (C) Eventuous HQ OÜ. All rights reserved // Licensed under the Apache License, Version 2.0. -namespace Eventuous.EventStore.Subscriptions; +namespace Eventuous.KurrentDB.Subscriptions; /// /// Options for diff --git a/src/EventStore/src/Eventuous.EventStore/Subscriptions/Options/AllStreamSubscriptionOptions.cs b/src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/Options/AllStreamSubscriptionOptions.cs similarity index 93% rename from src/EventStore/src/Eventuous.EventStore/Subscriptions/Options/AllStreamSubscriptionOptions.cs rename to src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/Options/AllStreamSubscriptionOptions.cs index 070cbe015..a4b6479a6 100644 --- a/src/EventStore/src/Eventuous.EventStore/Subscriptions/Options/AllStreamSubscriptionOptions.cs +++ b/src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/Options/AllStreamSubscriptionOptions.cs @@ -1,7 +1,7 @@ // Copyright (C) Eventuous HQ OÜ. All rights reserved // Licensed under the Apache License, Version 2.0. -namespace Eventuous.EventStore.Subscriptions; +namespace Eventuous.KurrentDB.Subscriptions; /// /// Options for diff --git a/src/EventStore/src/Eventuous.EventStore/Subscriptions/Options/CatchUpSubscriptionOptions.cs b/src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/Options/CatchUpSubscriptionOptions.cs similarity index 92% rename from src/EventStore/src/Eventuous.EventStore/Subscriptions/Options/CatchUpSubscriptionOptions.cs rename to src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/Options/CatchUpSubscriptionOptions.cs index 824d049ec..6cced6c8e 100644 --- a/src/EventStore/src/Eventuous.EventStore/Subscriptions/Options/CatchUpSubscriptionOptions.cs +++ b/src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/Options/CatchUpSubscriptionOptions.cs @@ -3,7 +3,7 @@ using Eventuous.Subscriptions.Filters; -namespace Eventuous.EventStore.Subscriptions; +namespace Eventuous.KurrentDB.Subscriptions; /// /// Base class for catch-up subscription options diff --git a/src/EventStore/src/Eventuous.EventStore/Subscriptions/Options/EventStoreSubscriptionOptions.cs b/src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/Options/EventStoreSubscriptionOptions.cs similarity index 91% rename from src/EventStore/src/Eventuous.EventStore/Subscriptions/Options/EventStoreSubscriptionOptions.cs rename to src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/Options/EventStoreSubscriptionOptions.cs index f49f06cd5..e187066b4 100644 --- a/src/EventStore/src/Eventuous.EventStore/Subscriptions/Options/EventStoreSubscriptionOptions.cs +++ b/src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/Options/EventStoreSubscriptionOptions.cs @@ -1,7 +1,7 @@ // Copyright (C) Eventuous HQ OÜ. All rights reserved // Licensed under the Apache License, Version 2.0. -namespace Eventuous.EventStore.Subscriptions; +namespace Eventuous.KurrentDB.Subscriptions; /// /// Base class for EventStoreDB subscription options diff --git a/src/EventStore/src/Eventuous.EventStore/Subscriptions/Options/EventStoreSubscriptionWithCheckpointOptions.cs b/src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/Options/EventStoreSubscriptionWithCheckpointOptions.cs similarity index 92% rename from src/EventStore/src/Eventuous.EventStore/Subscriptions/Options/EventStoreSubscriptionWithCheckpointOptions.cs rename to src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/Options/EventStoreSubscriptionWithCheckpointOptions.cs index 2130b7b8c..b18fd6533 100644 --- a/src/EventStore/src/Eventuous.EventStore/Subscriptions/Options/EventStoreSubscriptionWithCheckpointOptions.cs +++ b/src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/Options/EventStoreSubscriptionWithCheckpointOptions.cs @@ -1,7 +1,7 @@ // Copyright (C) Eventuous HQ OÜ. All rights reserved // Licensed under the Apache License, Version 2.0. -namespace Eventuous.EventStore.Subscriptions; +namespace Eventuous.KurrentDB.Subscriptions; /// /// Options base record for EventStoreDB checkpoint-based subscriptions diff --git a/src/EventStore/src/Eventuous.EventStore/Subscriptions/Options/PersistentSubscriptionOptions.cs b/src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/Options/PersistentSubscriptionOptions.cs similarity index 96% rename from src/EventStore/src/Eventuous.EventStore/Subscriptions/Options/PersistentSubscriptionOptions.cs rename to src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/Options/PersistentSubscriptionOptions.cs index be1cdba6c..1a7d23088 100644 --- a/src/EventStore/src/Eventuous.EventStore/Subscriptions/Options/PersistentSubscriptionOptions.cs +++ b/src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/Options/PersistentSubscriptionOptions.cs @@ -1,7 +1,7 @@ // Copyright (C) Eventuous HQ OÜ. All rights reserved // Licensed under the Apache License, Version 2.0. -namespace Eventuous.EventStore.Subscriptions; +namespace Eventuous.KurrentDB.Subscriptions; /// /// Base class for persistent subscription options diff --git a/src/EventStore/src/Eventuous.EventStore/Subscriptions/Options/StreamPersistentSubscriptionOptions.cs b/src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/Options/StreamPersistentSubscriptionOptions.cs similarity index 90% rename from src/EventStore/src/Eventuous.EventStore/Subscriptions/Options/StreamPersistentSubscriptionOptions.cs rename to src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/Options/StreamPersistentSubscriptionOptions.cs index 8864b0665..563b554fa 100644 --- a/src/EventStore/src/Eventuous.EventStore/Subscriptions/Options/StreamPersistentSubscriptionOptions.cs +++ b/src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/Options/StreamPersistentSubscriptionOptions.cs @@ -1,7 +1,7 @@ // Copyright (C) Eventuous HQ OÜ. All rights reserved // Licensed under the Apache License, Version 2.0. -namespace Eventuous.EventStore.Subscriptions; +namespace Eventuous.KurrentDB.Subscriptions; /// /// Options for diff --git a/src/EventStore/src/Eventuous.EventStore/Subscriptions/Options/StreamSubscriptionOptions.cs b/src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/Options/StreamSubscriptionOptions.cs similarity index 92% rename from src/EventStore/src/Eventuous.EventStore/Subscriptions/Options/StreamSubscriptionOptions.cs rename to src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/Options/StreamSubscriptionOptions.cs index 275c0c906..297618586 100644 --- a/src/EventStore/src/Eventuous.EventStore/Subscriptions/Options/StreamSubscriptionOptions.cs +++ b/src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/Options/StreamSubscriptionOptions.cs @@ -1,7 +1,7 @@ // Copyright (C) Eventuous HQ OÜ. All rights reserved // Licensed under the Apache License, Version 2.0. -namespace Eventuous.EventStore.Subscriptions; +namespace Eventuous.KurrentDB.Subscriptions; /// /// Options for diff --git a/src/EventStore/src/Eventuous.EventStore/Subscriptions/PersistentSubscriptionBase.cs b/src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/PersistentSubscriptionBase.cs similarity index 88% rename from src/EventStore/src/Eventuous.EventStore/Subscriptions/PersistentSubscriptionBase.cs rename to src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/PersistentSubscriptionBase.cs index c9312aa6c..a57e49634 100644 --- a/src/EventStore/src/Eventuous.EventStore/Subscriptions/PersistentSubscriptionBase.cs +++ b/src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/PersistentSubscriptionBase.cs @@ -8,13 +8,13 @@ // ReSharper disable SuggestBaseTypeForParameter -namespace Eventuous.EventStore.Subscriptions; +namespace Eventuous.KurrentDB.Subscriptions; /// /// Function type for handling event processing failures /// public delegate Task HandleEventProcessingFailure( - EventStoreClient client, + KurrentDBClient client, PersistentSubscription subscription, ResolvedEvent resolvedEvent, Exception exception @@ -28,12 +28,12 @@ public abstract class PersistentSubscriptionBase : EventSubscription where /// /// EventStoreDB persistent subscription client instance. /// - protected EventStorePersistentSubscriptionsClient SubscriptionClient { get; } + protected KurrentDBPersistentSubscriptionsClient SubscriptionClient { get; } /// /// EventStoreDB client instance. It's used for custom NACK behavior as well as for measuring the subscription gap. /// - protected EventStoreClient EventStoreClient { get; } + protected KurrentDBClient Client { get; } /// /// Metadata serializer instance. @@ -47,14 +47,14 @@ public abstract class PersistentSubscriptionBase : EventSubscription where /// /// EventStoreDB persistent subscription base class constructor /// - /// EventStoreDB client instance + /// EventStoreDB client instance /// Subscription options /// Consume pipe instance, provided automatically /// Optional logger factory /// Event payload serializer /// Metadata serializer protected PersistentSubscriptionBase( - EventStoreClient eventStoreClient, + KurrentDBClient client, T options, ConsumePipe consumePipe, ILoggerFactory? loggerFactory, @@ -62,9 +62,10 @@ protected PersistentSubscriptionBase( IMetadataSerializer? metaSerializer ) : base(options, consumePipe, loggerFactory, eventSerializer) { - EventStoreClient = eventStoreClient; + Client = client; MetadataSerializer = metaSerializer ?? DefaultMetadataSerializer.Instance; - var settings = eventStoreClient.GetSettings().Copy(); + + var settings = client.GetSettings().Copy(); var opSettings = settings.OperationOptions.Clone(); settings.OperationOptions = opSettings; SubscriptionClient = new(settings); @@ -75,27 +76,27 @@ protected PersistentSubscriptionBase( /// /// EventStoreDB persistent subscription base class constructor /// - /// EventStoreDB persistent subscription client instance + /// EventStoreDB persistent subscription client instance /// Subscription options /// Consume pipe instance, provided automatically /// Optional logger factory /// /// Metadata serializer protected PersistentSubscriptionBase( - EventStorePersistentSubscriptionsClient eventStoreClient, - T options, - ConsumePipe consumePipe, - ILoggerFactory? loggerFactory, - IEventSerializer? eventSerializer, - IMetadataSerializer? metaSerializer + KurrentDBPersistentSubscriptionsClient client, + T options, + ConsumePipe consumePipe, + ILoggerFactory? loggerFactory, + IEventSerializer? eventSerializer, + IMetadataSerializer? metaSerializer ) : base(options, consumePipe, loggerFactory, eventSerializer) { - SubscriptionClient = eventStoreClient; + SubscriptionClient = client; MetadataSerializer = metaSerializer ?? DefaultMetadataSerializer.Instance; - var settings = eventStoreClient.GetSettings().Copy(); + var settings = client.GetSettings().Copy(); var opSettings = settings.OperationOptions.Clone(); settings.OperationOptions = opSettings; - EventStoreClient = new(settings); + Client = new(settings); _handleEventProcessingFailure = options.FailureHandler ?? DefaultEventProcessingFailureHandler; if (options is { FailureHandler: not null, ThrowOnError: false }) Log.ThrowOnErrorIncompatible(); } @@ -190,7 +191,7 @@ async ValueTask Nack(MessageConsumeContext ctx, Exception exception) { var re = ctx.Items.GetItem(ResolvedEventKey); var subscription = ctx.Items.GetItem(SubscriptionKey)!; - await _handleEventProcessingFailure(EventStoreClient, subscription, re, exception).NoContext(); + await _handleEventProcessingFailure(Client, subscription, re, exception).NoContext(); } [RequiresDynamicCode(AttrConstants.DynamicSerializationMessage)] @@ -243,7 +244,7 @@ protected override async ValueTask Unsubscribe(CancellationToken cancellationTok } static Task DefaultEventProcessingFailureHandler( - EventStoreClient client, + KurrentDBClient client, PersistentSubscription subscription, ResolvedEvent resolvedEvent, Exception exception diff --git a/src/EventStore/src/Eventuous.EventStore/Subscriptions/StreamPersistentSubscription.cs b/src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/StreamPersistentSubscription.cs similarity index 76% rename from src/EventStore/src/Eventuous.EventStore/Subscriptions/StreamPersistentSubscription.cs rename to src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/StreamPersistentSubscription.cs index 04a30619c..2354cc9af 100644 --- a/src/EventStore/src/Eventuous.EventStore/Subscriptions/StreamPersistentSubscription.cs +++ b/src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/StreamPersistentSubscription.cs @@ -1,11 +1,11 @@ // Copyright (C) Eventuous HQ OÜ. All rights reserved // Licensed under the Apache License, Version 2.0. -using Eventuous.EventStore.Subscriptions.Diagnostics; +using Eventuous.KurrentDB.Subscriptions.Diagnostics; using Eventuous.Subscriptions.Diagnostics; using Eventuous.Subscriptions.Filters; -namespace Eventuous.EventStore.Subscriptions; +namespace Eventuous.KurrentDB.Subscriptions; /// /// Persistent subscription for EventStoreDB, for a specific stream @@ -14,45 +14,45 @@ public class StreamPersistentSubscription : PersistentSubscriptionBase /// EventStoreDB persistent subscription service for a given stream /// - /// EventStoreDB client instance + /// EventStoreDB client instance /// Persistent subscription options /// Consume pipe, provided automatically /// Optional logger factory /// Event serializer /// Metadata serializer public StreamPersistentSubscription( - EventStoreClient eventStoreClient, + KurrentDBClient client, StreamPersistentSubscriptionOptions options, ConsumePipe consumePipe, - ILoggerFactory? loggerFactory = null, + ILoggerFactory? loggerFactory = null, IEventSerializer? eventSerializer = null, - IMetadataSerializer? metaSerializer = null - ) : base(eventStoreClient, options, consumePipe, loggerFactory, eventSerializer, metaSerializer) + IMetadataSerializer? metaSerializer = null + ) : base(client, options, consumePipe, loggerFactory, eventSerializer, metaSerializer) => Ensure.NotEmptyString(options.StreamName); /// /// EventStoreDB persistent subscription service for a given stream /// - /// EventStoreDB persistent subscription client instance + /// EventStoreDB persistent subscription client instance /// Persistent subscription options /// Consume pipe, provided automatically /// Optional logger factory /// Event serializer /// Metadata serializer public StreamPersistentSubscription( - EventStorePersistentSubscriptionsClient eventStoreClient, - StreamPersistentSubscriptionOptions options, - ConsumePipe consumePipe, - ILoggerFactory? loggerFactory = null, - IEventSerializer? eventSerializer = null, - IMetadataSerializer? metaSerializer = null - ) : base(eventStoreClient, options, consumePipe, loggerFactory, eventSerializer, metaSerializer) + KurrentDBPersistentSubscriptionsClient client, + StreamPersistentSubscriptionOptions options, + ConsumePipe consumePipe, + ILoggerFactory? loggerFactory = null, + IEventSerializer? eventSerializer = null, + IMetadataSerializer? metaSerializer = null + ) : base(client, options, consumePipe, loggerFactory, eventSerializer, metaSerializer) => Ensure.NotEmptyString(options.StreamName); /// /// Creates EventStoreDB persistent subscription service for a given stream without using the options object /// - /// EventStoreDB gRPC client instance + /// EventStoreDB gRPC client instance /// Name of the stream to receive events from /// Subscription ID /// @@ -60,7 +60,7 @@ public StreamPersistentSubscription( /// /// public StreamPersistentSubscription( - EventStoreClient eventStoreClient, + KurrentDBClient client, StreamName streamName, string subscriptionId, ConsumePipe consumerPipe, @@ -68,7 +68,7 @@ public StreamPersistentSubscription( IMetadataSerializer? metaSerializer = null, ILoggerFactory? loggerFactory = null ) : this( - eventStoreClient, + client, new() { StreamName = streamName, SubscriptionId = subscriptionId @@ -111,5 +111,5 @@ CancellationToken cance /// public GetSubscriptionEndOfStream GetMeasure() - => new StreamSubscriptionMeasure(Options.SubscriptionId, Options.StreamName, EventStoreClient).GetEndOfStream; + => new StreamSubscriptionMeasure(Options.SubscriptionId, Options.StreamName, Client).GetEndOfStream; } diff --git a/src/EventStore/src/Eventuous.EventStore/Subscriptions/StreamSubscription.cs b/src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/StreamSubscription.cs similarity index 92% rename from src/EventStore/src/Eventuous.EventStore/Subscriptions/StreamSubscription.cs rename to src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/StreamSubscription.cs index 9ba4c227b..9d20167a5 100644 --- a/src/EventStore/src/Eventuous.EventStore/Subscriptions/StreamSubscription.cs +++ b/src/KurrentDB/src/Eventuous.KurrentDB/Subscriptions/StreamSubscription.cs @@ -7,7 +7,7 @@ using Eventuous.Subscriptions.Filters; using Eventuous.Tools; -namespace Eventuous.EventStore.Subscriptions; +namespace Eventuous.KurrentDB.Subscriptions; using Diagnostics; @@ -19,7 +19,7 @@ public class StreamSubscription : EventStoreCatchUpSubscriptionBase /// Creates EventStoreDB catch-up subscription service for a given stream /// - /// EventStoreDB gRPC client instance + /// EventStoreDB gRPC client instance /// Name of the stream to receive events from /// Subscription ID /// Checkpoint store instance @@ -29,7 +29,7 @@ public class StreamSubscription : EventStoreCatchUpSubscriptionBaseEither the subscription should throw an exception if an event handling fails /// Logger factory public StreamSubscription( - EventStoreClient eventStoreClient, + KurrentDBClient client, StreamName streamName, string subscriptionId, ICheckpointStore checkpointStore, @@ -40,7 +40,7 @@ public StreamSubscription( IMetadataSerializer? metaSerializer = null ) : this( - eventStoreClient, + client, new() { StreamName = streamName, SubscriptionId = subscriptionId, @@ -64,7 +64,7 @@ public StreamSubscription( /// Metadata serializer /// public StreamSubscription( - EventStoreClient client, + KurrentDBClient client, StreamSubscriptionOptions options, ICheckpointStore checkpointStore, ConsumePipe consumePipe, @@ -93,7 +93,7 @@ protected override async ValueTask Subscribe(CancellationToken cancellationToken var fromStream = position == null ? FromStream.Start : FromStream.After(StreamPosition.FromInt64((long)position)); - Subscription = await EventStoreClient.SubscribeToStreamAsync( + Subscription = await Client.SubscribeToStreamAsync( Options.StreamName, fromStream, (_, @event, ct) => HandleEvent(@event, ct), @@ -118,7 +118,7 @@ async Task HandleEvent(ResolvedEvent re, CancellationToken ct) { await HandleInternal(CreateContext(re, ct)).NoContext(); } - void HandleDrop(global::EventStore.Client.StreamSubscription _, SubscriptionDroppedReason reason, Exception? ex) + void HandleDrop(global::KurrentDB.Client.StreamSubscription _, SubscriptionDroppedReason reason, Exception? ex) => Dropped(EsdbMappings.AsDropReason(reason), ex); } @@ -162,5 +162,5 @@ MessageConsumeContext CreateContext(ResolvedEvent re, CancellationToken cancella /// /// public GetSubscriptionEndOfStream GetMeasure() - => new StreamSubscriptionMeasure(Options.SubscriptionId, Options.StreamName, EventStoreClient).GetEndOfStream; + => new StreamSubscriptionMeasure(Options.SubscriptionId, Options.StreamName, Client).GetEndOfStream; } diff --git a/src/EventStore/test/Eventuous.Tests.EventStore/AppServiceTests.cs b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/AppServiceTests.cs similarity index 97% rename from src/EventStore/test/Eventuous.Tests.EventStore/AppServiceTests.cs rename to src/KurrentDB/test/Eventuous.Tests.KurrentDB/AppServiceTests.cs index 54b8c3a62..b3e5ceffc 100644 --- a/src/EventStore/test/Eventuous.Tests.EventStore/AppServiceTests.cs +++ b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/AppServiceTests.cs @@ -3,7 +3,7 @@ using Eventuous.TestHelpers.TUnit; using Shouldly; -namespace Eventuous.Tests.EventStore; +namespace Eventuous.Tests.KurrentDB; [ClassDataSource(Shared = SharedType.None)] public class AppServiceTests { diff --git a/src/EventStore/test/Eventuous.Tests.EventStore/Eventuous.Tests.EventStore.csproj b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/Eventuous.Tests.KurrentDB.csproj similarity index 92% rename from src/EventStore/test/Eventuous.Tests.EventStore/Eventuous.Tests.EventStore.csproj rename to src/KurrentDB/test/Eventuous.Tests.KurrentDB/Eventuous.Tests.KurrentDB.csproj index 39039de13..2fac56c41 100644 --- a/src/EventStore/test/Eventuous.Tests.EventStore/Eventuous.Tests.EventStore.csproj +++ b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/Eventuous.Tests.KurrentDB.csproj @@ -9,7 +9,7 @@ - + @@ -28,7 +28,7 @@ - + diff --git a/src/EventStore/test/Eventuous.Tests.EventStore/Fixtures/DomainFixture.cs b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/Fixtures/DomainFixture.cs similarity index 94% rename from src/EventStore/test/Eventuous.Tests.EventStore/Fixtures/DomainFixture.cs rename to src/KurrentDB/test/Eventuous.Tests.KurrentDB/Fixtures/DomainFixture.cs index 4b6ae12d7..8155acd7a 100644 --- a/src/EventStore/test/Eventuous.Tests.EventStore/Fixtures/DomainFixture.cs +++ b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/Fixtures/DomainFixture.cs @@ -2,7 +2,7 @@ using Eventuous.Sut.App; using Eventuous.Sut.Domain; -namespace Eventuous.Tests.EventStore.Fixtures; +namespace Eventuous.Tests.KurrentDB.Fixtures; public static class DomainFixture { static DomainFixture() => TypeMap.RegisterKnownEventTypes(typeof(BookingEvents.BookingImported).Assembly); diff --git a/src/EventStore/test/Eventuous.Tests.EventStore/Fixtures/EsdbContainer.cs b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/Fixtures/EsdbContainer.cs similarity index 91% rename from src/EventStore/test/Eventuous.Tests.EventStore/Fixtures/EsdbContainer.cs rename to src/KurrentDB/test/Eventuous.Tests.KurrentDB/Fixtures/EsdbContainer.cs index bf4690c6a..d9251572d 100644 --- a/src/EventStore/test/Eventuous.Tests.EventStore/Fixtures/EsdbContainer.cs +++ b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/Fixtures/EsdbContainer.cs @@ -1,7 +1,7 @@ using System.Runtime.InteropServices; using Testcontainers.EventStoreDb; -namespace Eventuous.Tests.EventStore.Fixtures; +namespace Eventuous.Tests.KurrentDB.Fixtures; public static class EsdbContainer { public static EventStoreDbContainer Create() { diff --git a/src/EventStore/test/Eventuous.Tests.EventStore/Fixtures/StoreFixture.cs b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/Fixtures/StoreFixture.cs similarity index 84% rename from src/EventStore/test/Eventuous.Tests.EventStore/Fixtures/StoreFixture.cs rename to src/KurrentDB/test/Eventuous.Tests.KurrentDB/Fixtures/StoreFixture.cs index ea5db540b..805e7c9e4 100644 --- a/src/EventStore/test/Eventuous.Tests.EventStore/Fixtures/StoreFixture.cs +++ b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/Fixtures/StoreFixture.cs @@ -1,16 +1,16 @@ using System.Diagnostics; -using EventStore.Client; using Eventuous.Diagnostics; -using Eventuous.EventStore; +using Eventuous.KurrentDB; using Eventuous.Tests.Persistence.Base.Fixtures; +using KurrentDB.Client; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Testcontainers.EventStoreDb; -namespace Eventuous.Tests.EventStore.Fixtures; +namespace Eventuous.Tests.KurrentDB.Fixtures; public class StoreFixture : StoreFixtureBase { - public EventStoreClient Client { get; private set; } = null!; + public KurrentDBClient Client { get; private set; } = null!; #pragma warning disable CS0618 // Type or member is obsolete public IAggregateStore AggregateStore { get; private set; } = null!; #pragma warning restore CS0618 // Type or member is obsolete @@ -26,7 +26,7 @@ public StoreFixture(LogLevel logLevel) : base(logLevel) { } protected override void SetupServices(IServiceCollection services) { - services.AddEventStoreClient(Container.GetConnectionString()); + services.AddKurrentDBClient(Container.GetConnectionString()); services.AddEventStore(); #pragma warning disable CS0618 // Type or member is obsolete services.AddSingleton(); @@ -36,7 +36,7 @@ protected override void SetupServices(IServiceCollection services) { protected override EventStoreDbContainer CreateContainer() => EsdbContainer.Create(); protected override void GetDependencies(IServiceProvider provider) { - Client = provider.GetRequiredService(); + Client = provider.GetRequiredService(); #pragma warning disable CS0618 // Type or member is obsolete AggregateStore = Provider.GetRequiredService(); #pragma warning restore CS0618 // Type or member is obsolete diff --git a/src/EventStore/test/Eventuous.Tests.EventStore/Fixtures/TestCheckpointStore.cs b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/Fixtures/TestCheckpointStore.cs similarity index 94% rename from src/EventStore/test/Eventuous.Tests.EventStore/Fixtures/TestCheckpointStore.cs rename to src/KurrentDB/test/Eventuous.Tests.KurrentDB/Fixtures/TestCheckpointStore.cs index abc9c2e4c..0f85d6274 100644 --- a/src/EventStore/test/Eventuous.Tests.EventStore/Fixtures/TestCheckpointStore.cs +++ b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/Fixtures/TestCheckpointStore.cs @@ -1,4 +1,4 @@ -namespace Eventuous.Tests.EventStore.Fixtures; +namespace Eventuous.Tests.KurrentDB.Fixtures; public class TestCheckpointStore : ICheckpointStore { readonly Dictionary _checkpoints = new(); diff --git a/src/EventStore/test/Eventuous.Tests.EventStore/Limiter.cs b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/Limiter.cs similarity index 65% rename from src/EventStore/test/Eventuous.Tests.EventStore/Limiter.cs rename to src/KurrentDB/test/Eventuous.Tests.KurrentDB/Limiter.cs index 7a9625204..1c9304493 100644 --- a/src/EventStore/test/Eventuous.Tests.EventStore/Limiter.cs +++ b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/Limiter.cs @@ -1,9 +1,9 @@ -using Eventuous.Tests.EventStore; +using Eventuous.Tests.KurrentDB; using TUnit.Core.Interfaces; [assembly: ParallelLimiter] -namespace Eventuous.Tests.EventStore; +namespace Eventuous.Tests.KurrentDB; public class Limiter : IParallelLimit { public int Limit => 4; diff --git a/src/EventStore/test/Eventuous.Tests.EventStore/Metrics/MetricsFixture.cs b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/Metrics/MetricsFixture.cs similarity index 58% rename from src/EventStore/test/Eventuous.Tests.EventStore/Metrics/MetricsFixture.cs rename to src/KurrentDB/test/Eventuous.Tests.KurrentDB/Metrics/MetricsFixture.cs index 30e1a0292..58a7d439d 100644 --- a/src/EventStore/test/Eventuous.Tests.EventStore/Metrics/MetricsFixture.cs +++ b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/Metrics/MetricsFixture.cs @@ -1,20 +1,20 @@ -using Eventuous.EventStore; -using Eventuous.EventStore.Producers; -using Eventuous.EventStore.Subscriptions; +using Eventuous.KurrentDB; +using Eventuous.KurrentDB.Producers; +using Eventuous.KurrentDB.Subscriptions; using Eventuous.Tests.OpenTelemetry.Fixtures; using Microsoft.Extensions.DependencyInjection; using Testcontainers.EventStoreDb; -namespace Eventuous.Tests.EventStore.Metrics; +namespace Eventuous.Tests.KurrentDB.Metrics; -public class MetricsFixture : MetricsSubscriptionFixtureBase { +public class MetricsFixture : MetricsSubscriptionFixtureBase { protected override EventStoreDbContainer CreateContainer() => EsdbContainer.Create(); protected override void ConfigureSubscription(StreamSubscriptionOptions options) => options.StreamName = Stream; protected override void SetupServices(IServiceCollection services) { base.SetupServices(services); - services.AddEventStoreClient(Container.GetConnectionString()); - services.AddEventStore(); + services.AddKurrentDBClient(Container.GetConnectionString()); + services.AddEventStore(); } } diff --git a/src/EventStore/test/Eventuous.Tests.EventStore/Metrics/MetricsTests.cs b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/Metrics/MetricsTests.cs similarity index 87% rename from src/EventStore/test/Eventuous.Tests.EventStore/Metrics/MetricsTests.cs rename to src/KurrentDB/test/Eventuous.Tests.KurrentDB/Metrics/MetricsTests.cs index fd1539e82..efef9ddb2 100644 --- a/src/EventStore/test/Eventuous.Tests.EventStore/Metrics/MetricsTests.cs +++ b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/Metrics/MetricsTests.cs @@ -1,6 +1,6 @@ using Eventuous.Tests.OpenTelemetry; -namespace Eventuous.Tests.EventStore.Metrics; +namespace Eventuous.Tests.KurrentDB.Metrics; [ClassDataSource] [NotInParallel] diff --git a/src/EventStore/test/Eventuous.Tests.EventStore/ProducerTracesTests.cs b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/ProducerTracesTests.cs similarity index 96% rename from src/EventStore/test/Eventuous.Tests.EventStore/ProducerTracesTests.cs rename to src/KurrentDB/test/Eventuous.Tests.KurrentDB/ProducerTracesTests.cs index 086e2749f..1a654dcf9 100644 --- a/src/EventStore/test/Eventuous.Tests.EventStore/ProducerTracesTests.cs +++ b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/ProducerTracesTests.cs @@ -2,11 +2,11 @@ using Eventuous.Diagnostics; using Eventuous.Producers; using Eventuous.TestHelpers; -using Eventuous.Tests.EventStore.Subscriptions.Fixtures; +using Eventuous.Tests.KurrentDB.Subscriptions.Fixtures; using Eventuous.Tests.Subscriptions.Base; using Shouldly; -namespace Eventuous.Tests.EventStore; +namespace Eventuous.Tests.KurrentDB; public class TracesTests : LegacySubscriptionFixture { readonly ActivityListener _listener; diff --git a/src/EventStore/test/Eventuous.Tests.EventStore/RegistrationTests.cs b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/RegistrationTests.cs similarity index 88% rename from src/EventStore/test/Eventuous.Tests.EventStore/RegistrationTests.cs rename to src/KurrentDB/test/Eventuous.Tests.KurrentDB/RegistrationTests.cs index 6b72f8419..6f06e031f 100644 --- a/src/EventStore/test/Eventuous.Tests.EventStore/RegistrationTests.cs +++ b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/RegistrationTests.cs @@ -1,12 +1,12 @@ -using EventStore.Client; -using Eventuous.EventStore.Subscriptions; +using Eventuous.KurrentDB.Subscriptions; using Eventuous.Subscriptions.Context; using Eventuous.TestHelpers; +using KurrentDB.Client; using Microsoft.Extensions.DependencyInjection; using Shouldly; -using StreamSubscription = Eventuous.EventStore.Subscriptions.StreamSubscription; +using StreamSubscription = Eventuous.KurrentDB.Subscriptions.StreamSubscription; -namespace Eventuous.Tests.EventStore; +namespace Eventuous.Tests.KurrentDB; [ClassDataSource] public class RegistrationTests(StoreFixture fixture) { @@ -31,7 +31,7 @@ public void ShouldResolveSubscription() { [Test] [Category("Dependency injection")] public void ShouldHaveEventStoreClient() { - var client = Sub.GetPrivateMember("EventStoreClient"); + var client = Sub.GetPrivateMember("Client"); client.ShouldBe(fixture.Client); } diff --git a/src/EventStore/test/Eventuous.Tests.EventStore/Store/AggregateStoreTests.cs b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/Store/AggregateStoreTests.cs similarity index 98% rename from src/EventStore/test/Eventuous.Tests.EventStore/Store/AggregateStoreTests.cs rename to src/KurrentDB/test/Eventuous.Tests.KurrentDB/Store/AggregateStoreTests.cs index bcf5f576a..aba53d925 100644 --- a/src/EventStore/test/Eventuous.Tests.EventStore/Store/AggregateStoreTests.cs +++ b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/Store/AggregateStoreTests.cs @@ -4,7 +4,7 @@ using static Eventuous.AggregateFactoryRegistry; using LoggingExtensions = Eventuous.TestHelpers.TUnit.Logging.LoggingExtensions; -namespace Eventuous.Tests.EventStore.Store; +namespace Eventuous.Tests.KurrentDB.Store; [ClassDataSource] public class AggregateStoreTests { diff --git a/src/EventStore/test/Eventuous.Tests.EventStore/Store/EventStoreAggregateTests.cs b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/Store/EventStoreAggregateTests.cs similarity index 98% rename from src/EventStore/test/Eventuous.Tests.EventStore/Store/EventStoreAggregateTests.cs rename to src/KurrentDB/test/Eventuous.Tests.KurrentDB/Store/EventStoreAggregateTests.cs index 87796371b..bf79f312e 100644 --- a/src/EventStore/test/Eventuous.Tests.EventStore/Store/EventStoreAggregateTests.cs +++ b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/Store/EventStoreAggregateTests.cs @@ -4,7 +4,7 @@ using static Eventuous.AggregateFactoryRegistry; using LoggingExtensions = Eventuous.TestHelpers.TUnit.Logging.LoggingExtensions; -namespace Eventuous.Tests.EventStore.Store; +namespace Eventuous.Tests.KurrentDB.Store; [ClassDataSource] public class EventStoreAggregateTests { diff --git a/src/EventStore/test/Eventuous.Tests.EventStore/Store/StoreTests.cs b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/Store/StoreTests.cs similarity index 91% rename from src/EventStore/test/Eventuous.Tests.EventStore/Store/StoreTests.cs rename to src/KurrentDB/test/Eventuous.Tests.KurrentDB/Store/StoreTests.cs index 5b050bdba..162cf711b 100644 --- a/src/EventStore/test/Eventuous.Tests.EventStore/Store/StoreTests.cs +++ b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/Store/StoreTests.cs @@ -2,7 +2,7 @@ // ReSharper disable UnusedType.Global -namespace Eventuous.Tests.EventStore.Store; +namespace Eventuous.Tests.KurrentDB.Store; [InheritsTests] [ClassDataSource] diff --git a/src/EventStore/test/Eventuous.Tests.EventStore/Store/TieredStoreTests.cs b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/Store/TieredStoreTests.cs similarity index 89% rename from src/EventStore/test/Eventuous.Tests.EventStore/Store/TieredStoreTests.cs rename to src/KurrentDB/test/Eventuous.Tests.KurrentDB/Store/TieredStoreTests.cs index 2253c8bf9..c7618349a 100644 --- a/src/EventStore/test/Eventuous.Tests.EventStore/Store/TieredStoreTests.cs +++ b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/Store/TieredStoreTests.cs @@ -1,7 +1,7 @@ using Eventuous.Tests.Persistence.Base.Store; using Testcontainers.EventStoreDb; -namespace Eventuous.Tests.EventStore.Store; +namespace Eventuous.Tests.KurrentDB.Store; [ClassDataSource] public class TieredStoreTests(StoreFixture storeFixture) : TieredStoreTestsBase(storeFixture) { diff --git a/src/EventStore/test/Eventuous.Tests.EventStore/Subscriptions/CustomDependenciesTests.cs b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/Subscriptions/CustomDependenciesTests.cs similarity index 94% rename from src/EventStore/test/Eventuous.Tests.EventStore/Subscriptions/CustomDependenciesTests.cs rename to src/KurrentDB/test/Eventuous.Tests.KurrentDB/Subscriptions/CustomDependenciesTests.cs index b1c54a79e..caae4ad13 100644 --- a/src/EventStore/test/Eventuous.Tests.EventStore/Subscriptions/CustomDependenciesTests.cs +++ b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/Subscriptions/CustomDependenciesTests.cs @@ -1,8 +1,8 @@ // Copyright (C) Eventuous HQ OÜ. All rights reserved // Licensed under the Apache License, Version 2.0. -using Eventuous.EventStore.Producers; -using Eventuous.EventStore.Subscriptions; +using Eventuous.KurrentDB.Producers; +using Eventuous.KurrentDB.Subscriptions; using Eventuous.Producers; using Eventuous.Subscriptions.Context; using Eventuous.Subscriptions.Registrations; @@ -12,7 +12,7 @@ using Microsoft.Extensions.Hosting; using Testcontainers.EventStoreDb; -namespace Eventuous.Tests.EventStore.Subscriptions; +namespace Eventuous.Tests.KurrentDB.Subscriptions; public class CustomDependenciesTests { readonly TestSerializer _serializer = new(); @@ -31,8 +31,8 @@ public async Task Setup(CancellationToken cancellationToken) { services.AddLogging(b => b.AddFilter("Grpc", LogLevel.Error).AddConsole().AddTUnit(LogLevel.Debug)); - services.AddEventStoreClient(_container.GetConnectionString()); - services.AddProducer(); + services.AddKurrentDBClient(_container.GetConnectionString()); + services.AddProducer(); // Add NoOp store globally to make sure it's not picked up services.AddCheckpointStore(); diff --git a/src/EventStore/test/Eventuous.Tests.EventStore/Subscriptions/Fixtures/CatchUpSubscriptionFixture.cs b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/Subscriptions/Fixtures/CatchUpSubscriptionFixture.cs similarity index 87% rename from src/EventStore/test/Eventuous.Tests.EventStore/Subscriptions/Fixtures/CatchUpSubscriptionFixture.cs rename to src/KurrentDB/test/Eventuous.Tests.KurrentDB/Subscriptions/Fixtures/CatchUpSubscriptionFixture.cs index 8bda79ec9..78d083dab 100644 --- a/src/EventStore/test/Eventuous.Tests.EventStore/Subscriptions/Fixtures/CatchUpSubscriptionFixture.cs +++ b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/Subscriptions/Fixtures/CatchUpSubscriptionFixture.cs @@ -1,11 +1,11 @@ -using EventStore.Client; -using Eventuous.EventStore; -using Eventuous.EventStore.Subscriptions; +using Eventuous.KurrentDB; +using Eventuous.KurrentDB.Subscriptions; using Eventuous.Tests.Subscriptions.Base; +using KurrentDB.Client; using Microsoft.Extensions.DependencyInjection; using Testcontainers.EventStoreDb; -namespace Eventuous.Tests.EventStore.Subscriptions.Fixtures; +namespace Eventuous.Tests.KurrentDB.Subscriptions.Fixtures; public class CatchUpSubscriptionFixture( Action configureOptions, @@ -25,18 +25,18 @@ public class CatchUpSubscriptionFixture(); + services.AddKurrentDBClient(Container.GetConnectionString()); + services.AddEventStore(); services.AddSingleton(new TestEventHandlerOptions()); configureServices?.Invoke(services); } protected override void GetDependencies(IServiceProvider provider) { base.GetDependencies(provider); - Client = provider.GetRequiredService(); + Client = provider.GetRequiredService(); } - public EventStoreClient Client { get; set; } = null!; + public KurrentDBClient Client { get; set; } = null!; protected override ILoggingBuilder ConfigureLogging(ILoggingBuilder builder) => base.ConfigureLogging(builder).AddFilter(Filter); diff --git a/src/EventStore/test/Eventuous.Tests.EventStore/Subscriptions/Fixtures/LegacySubscriptionFixture.cs b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/Subscriptions/Fixtures/LegacySubscriptionFixture.cs similarity index 92% rename from src/EventStore/test/Eventuous.Tests.EventStore/Subscriptions/Fixtures/LegacySubscriptionFixture.cs rename to src/KurrentDB/test/Eventuous.Tests.KurrentDB/Subscriptions/Fixtures/LegacySubscriptionFixture.cs index e7b3605b2..11792ef22 100644 --- a/src/EventStore/test/Eventuous.Tests.EventStore/Subscriptions/Fixtures/LegacySubscriptionFixture.cs +++ b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/Subscriptions/Fixtures/LegacySubscriptionFixture.cs @@ -1,17 +1,17 @@ -using Eventuous.EventStore.Producers; -using Eventuous.EventStore.Subscriptions; +using Eventuous.KurrentDB.Producers; +using Eventuous.KurrentDB.Subscriptions; using Eventuous.Subscriptions.Filters; using Eventuous.Tests.Subscriptions.Base; using TUnit.Core.Interfaces; using LoggingExtensions = Eventuous.TestHelpers.TUnit.Logging.LoggingExtensions; -namespace Eventuous.Tests.EventStore.Subscriptions.Fixtures; +namespace Eventuous.Tests.KurrentDB.Subscriptions.Fixtures; public abstract class LegacySubscriptionFixture : IAsyncInitializer, IAsyncDisposable where T : class, IEventHandler { protected StreamName Stream { get; } = new($"test-{Guid.NewGuid():N}"); protected StoreFixture StoreFixture { get; } protected T Handler { get; } - protected EventStoreProducer Producer { get; private set; } = null!; + protected KurrentDbProducer Producer { get; private set; } = null!; protected ILogger Log { get; } protected TestCheckpointStore CheckpointStore { get; } = new(); protected StreamSubscription Subscription { get; set; } = null!; diff --git a/src/EventStore/test/Eventuous.Tests.EventStore/Subscriptions/Fixtures/PersistentSubscriptionFixture.cs b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/Subscriptions/Fixtures/PersistentSubscriptionFixture.cs similarity index 90% rename from src/EventStore/test/Eventuous.Tests.EventStore/Subscriptions/Fixtures/PersistentSubscriptionFixture.cs rename to src/KurrentDB/test/Eventuous.Tests.KurrentDB/Subscriptions/Fixtures/PersistentSubscriptionFixture.cs index 835d312bd..b7b73efd7 100644 --- a/src/EventStore/test/Eventuous.Tests.EventStore/Subscriptions/Fixtures/PersistentSubscriptionFixture.cs +++ b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/Subscriptions/Fixtures/PersistentSubscriptionFixture.cs @@ -1,10 +1,10 @@ using Eventuous.Diagnostics.Logging; -using Eventuous.EventStore.Producers; -using Eventuous.EventStore.Subscriptions; +using Eventuous.KurrentDB.Producers; +using Eventuous.KurrentDB.Subscriptions; using Eventuous.Tests.Subscriptions.Base; using LoggingExtensions = Eventuous.TestHelpers.TUnit.Logging.LoggingExtensions; -namespace Eventuous.Tests.EventStore.Subscriptions.Fixtures; +namespace Eventuous.Tests.KurrentDB.Subscriptions.Fixtures; public class PersistentSubscriptionFixture( THandler handler, @@ -17,7 +17,7 @@ public class PersistentSubscriptionFixture( where TOptions : PersistentSubscriptionOptions { public StreamName Stream { get; } = new($"test-{Guid.NewGuid():N}"); public THandler Handler { get; } = handler; - public EventStoreProducer Producer { get; private set; } = null!; + public KurrentDbProducer Producer { get; private set; } = null!; protected ILogger Log { get; set; } = null!; protected StoreFixture Fixture { get; } = new(logLevel); TSubscription Subscription { get; set; } = null!; diff --git a/src/EventStore/test/Eventuous.Tests.EventStore/Subscriptions/PublishAndSubscribeManyPartitionedTests.cs b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/Subscriptions/PublishAndSubscribeManyPartitionedTests.cs similarity index 88% rename from src/EventStore/test/Eventuous.Tests.EventStore/Subscriptions/PublishAndSubscribeManyPartitionedTests.cs rename to src/KurrentDB/test/Eventuous.Tests.KurrentDB/Subscriptions/PublishAndSubscribeManyPartitionedTests.cs index 58a31fe9e..3028d6884 100644 --- a/src/EventStore/test/Eventuous.Tests.EventStore/Subscriptions/PublishAndSubscribeManyPartitionedTests.cs +++ b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/Subscriptions/PublishAndSubscribeManyPartitionedTests.cs @@ -1,10 +1,10 @@ using Eventuous.Producers; using Eventuous.TestHelpers.TUnit; -using Eventuous.Tests.EventStore.Subscriptions.Fixtures; +using Eventuous.Tests.KurrentDB.Subscriptions.Fixtures; using Eventuous.Tests.Subscriptions.Base; using Shouldly; -namespace Eventuous.Tests.EventStore.Subscriptions; +namespace Eventuous.Tests.KurrentDB.Subscriptions; public class PublishAndSubscribeManyPartitionedTests() : LegacySubscriptionFixture(5.Milliseconds(), false, new StreamName(Guid.NewGuid().ToString("N"))) { [Test] diff --git a/src/EventStore/test/Eventuous.Tests.EventStore/Subscriptions/PublishAndSubscribeManyTests.cs b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/Subscriptions/PublishAndSubscribeManyTests.cs similarity index 87% rename from src/EventStore/test/Eventuous.Tests.EventStore/Subscriptions/PublishAndSubscribeManyTests.cs rename to src/KurrentDB/test/Eventuous.Tests.KurrentDB/Subscriptions/PublishAndSubscribeManyTests.cs index 92947d9ac..2ad4e67ef 100644 --- a/src/EventStore/test/Eventuous.Tests.EventStore/Subscriptions/PublishAndSubscribeManyTests.cs +++ b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/Subscriptions/PublishAndSubscribeManyTests.cs @@ -1,10 +1,10 @@ using Eventuous.Producers; using Eventuous.TestHelpers.TUnit; -using Eventuous.Tests.EventStore.Subscriptions.Fixtures; +using Eventuous.Tests.KurrentDB.Subscriptions.Fixtures; using Eventuous.Tests.Subscriptions.Base; using Shouldly; -namespace Eventuous.Tests.EventStore.Subscriptions; +namespace Eventuous.Tests.KurrentDB.Subscriptions; public class PublishAndSubscribeManyTests() : LegacySubscriptionFixture(1.Milliseconds(), false) { [Test] diff --git a/src/EventStore/test/Eventuous.Tests.EventStore/Subscriptions/PublishAndSubscribeOneTests.cs b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/Subscriptions/PublishAndSubscribeOneTests.cs similarity index 87% rename from src/EventStore/test/Eventuous.Tests.EventStore/Subscriptions/PublishAndSubscribeOneTests.cs rename to src/KurrentDB/test/Eventuous.Tests.KurrentDB/Subscriptions/PublishAndSubscribeOneTests.cs index 0e3b5d484..7f5ed7cb6 100644 --- a/src/EventStore/test/Eventuous.Tests.EventStore/Subscriptions/PublishAndSubscribeOneTests.cs +++ b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/Subscriptions/PublishAndSubscribeOneTests.cs @@ -1,10 +1,10 @@ using Eventuous.Producers; using Eventuous.TestHelpers.TUnit; -using Eventuous.Tests.EventStore.Subscriptions.Fixtures; +using Eventuous.Tests.KurrentDB.Subscriptions.Fixtures; using Eventuous.Tests.Subscriptions.Base; using Shouldly; -namespace Eventuous.Tests.EventStore.Subscriptions; +namespace Eventuous.Tests.KurrentDB.Subscriptions; public class PublishAndSubscribeOneTests() : LegacySubscriptionFixture(null, false) { [Test] diff --git a/src/EventStore/test/Eventuous.Tests.EventStore/Subscriptions/StreamPersistentPublishAndSubscribeManyTests.cs b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/Subscriptions/StreamPersistentPublishAndSubscribeManyTests.cs similarity index 83% rename from src/EventStore/test/Eventuous.Tests.EventStore/Subscriptions/StreamPersistentPublishAndSubscribeManyTests.cs rename to src/KurrentDB/test/Eventuous.Tests.KurrentDB/Subscriptions/StreamPersistentPublishAndSubscribeManyTests.cs index cd0c09ba0..cbe506996 100644 --- a/src/EventStore/test/Eventuous.Tests.EventStore/Subscriptions/StreamPersistentPublishAndSubscribeManyTests.cs +++ b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/Subscriptions/StreamPersistentPublishAndSubscribeManyTests.cs @@ -1,12 +1,12 @@ -using EventStore.Client; -using Eventuous.EventStore.Subscriptions; +using Eventuous.KurrentDB.Subscriptions; using Eventuous.Producers; using Eventuous.Subscriptions.Filters; using Eventuous.TestHelpers.TUnit; -using Eventuous.Tests.EventStore.Subscriptions.Fixtures; +using Eventuous.Tests.KurrentDB.Subscriptions.Fixtures; using Eventuous.Tests.Subscriptions.Base; +using KurrentDB.Client; -namespace Eventuous.Tests.EventStore.Subscriptions; +namespace Eventuous.Tests.KurrentDB.Subscriptions; public class StreamPersistentPublishAndSubscribeManyTests { [Test] @@ -34,10 +34,10 @@ public static IEnumerable HandleEvent(IMessageConsumeContex protected override void SetupServices(IServiceCollection services) { base.SetupServices(services); - services.AddProducer(); + services.AddProducer(); services .AddSubscription( diff --git a/src/EventStore/test/Eventuous.Tests.EventStore/Subscriptions/SubscribeTests.cs b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/Subscriptions/SubscribeTests.cs similarity index 94% rename from src/EventStore/test/Eventuous.Tests.EventStore/Subscriptions/SubscribeTests.cs rename to src/KurrentDB/test/Eventuous.Tests.KurrentDB/Subscriptions/SubscribeTests.cs index 770146c70..77ef9e846 100644 --- a/src/EventStore/test/Eventuous.Tests.EventStore/Subscriptions/SubscribeTests.cs +++ b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/Subscriptions/SubscribeTests.cs @@ -1,11 +1,11 @@ -using Eventuous.EventStore.Subscriptions; -using Eventuous.Tests.EventStore.Subscriptions.Fixtures; +using Eventuous.KurrentDB.Subscriptions; +using Eventuous.Tests.KurrentDB.Subscriptions.Fixtures; using Eventuous.Tests.Subscriptions.Base; using Testcontainers.EventStoreDb; // ReSharper disable UnusedType.Global -namespace Eventuous.Tests.EventStore.Subscriptions; +namespace Eventuous.Tests.KurrentDB.Subscriptions; public class SubscribeToAll() : SubscribeToAllBase( diff --git a/src/EventStore/test/Eventuous.Tests.EventStore/Subscriptions/SubscriptionIgnoredMessagesTests.cs b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/Subscriptions/SubscriptionIgnoredMessagesTests.cs similarity index 94% rename from src/EventStore/test/Eventuous.Tests.EventStore/Subscriptions/SubscriptionIgnoredMessagesTests.cs rename to src/KurrentDB/test/Eventuous.Tests.KurrentDB/Subscriptions/SubscriptionIgnoredMessagesTests.cs index 948d2ac0a..db506d5fc 100644 --- a/src/EventStore/test/Eventuous.Tests.EventStore/Subscriptions/SubscriptionIgnoredMessagesTests.cs +++ b/src/KurrentDB/test/Eventuous.Tests.KurrentDB/Subscriptions/SubscriptionIgnoredMessagesTests.cs @@ -1,5 +1,5 @@ -using Eventuous.EventStore.Producers; -using Eventuous.EventStore.Subscriptions; +using Eventuous.KurrentDB.Producers; +using Eventuous.KurrentDB.Subscriptions; using Eventuous.Producers; using Eventuous.Subscriptions.Registrations; using Eventuous.TestHelpers.TUnit; @@ -9,7 +9,7 @@ // ReSharper disable MethodHasAsyncOverload -namespace Eventuous.Tests.EventStore.Subscriptions; +namespace Eventuous.Tests.KurrentDB.Subscriptions; public class SubscriptionIgnoredMessagesTests : StoreFixture { readonly string _subscriptionId = $"test-{Guid.NewGuid():N}"; @@ -57,7 +57,7 @@ IEnumerable Generate() { protected override void SetupServices(IServiceCollection services) { base.SetupServices(services); - services.AddProducer(); + services.AddProducer(); services.AddSubscription( _subscriptionId, diff --git a/src/Mongo/test/Eventuous.Tests.Projections.MongoDB/Eventuous.Tests.Projections.MongoDB.csproj b/src/Mongo/test/Eventuous.Tests.Projections.MongoDB/Eventuous.Tests.Projections.MongoDB.csproj index 93be8993c..a446b3a12 100644 --- a/src/Mongo/test/Eventuous.Tests.Projections.MongoDB/Eventuous.Tests.Projections.MongoDB.csproj +++ b/src/Mongo/test/Eventuous.Tests.Projections.MongoDB/Eventuous.Tests.Projections.MongoDB.csproj @@ -6,7 +6,7 @@ Exe - + diff --git a/src/Mongo/test/Eventuous.Tests.Projections.MongoDB/Fixtures/IntegrationFixture.cs b/src/Mongo/test/Eventuous.Tests.Projections.MongoDB/Fixtures/IntegrationFixture.cs index e518342ff..6b0c902fe 100644 --- a/src/Mongo/test/Eventuous.Tests.Projections.MongoDB/Fixtures/IntegrationFixture.cs +++ b/src/Mongo/test/Eventuous.Tests.Projections.MongoDB/Fixtures/IntegrationFixture.cs @@ -1,7 +1,7 @@ using System.Runtime.InteropServices; -using EventStore.Client; -using Eventuous.EventStore; +using Eventuous.KurrentDB; using Eventuous.TestHelpers; +using KurrentDB.Client; using MongoDb.Bson.NodaTime; using MongoDB.Driver; using Testcontainers.EventStoreDb; @@ -12,7 +12,7 @@ namespace Eventuous.Tests.Projections.MongoDB.Fixtures; public sealed class IntegrationFixture : IAsyncInitializer, IAsyncDisposable { public IEventStore EventStore { get; set; } = null!; - public EventStoreClient Client { get; private set; } = null!; + public KurrentDBClient Client { get; private set; } = null!; public IMongoDatabase Mongo { get; private set; } = null!; static IEventSerializer Serializer { get; } = new DefaultEventSerializer(TestPrimitives.DefaultOptions); @@ -39,9 +39,9 @@ public async Task InitializeAsync() { : "eventstore/eventstore:24.6"; _esdbContainer = new EventStoreDbBuilder().WithImage(image).Build(); await _esdbContainer.StartAsync(); - var settings = EventStoreClientSettings.Create(_esdbContainer.GetConnectionString()); + var settings = KurrentDBClientSettings.Create(_esdbContainer.GetConnectionString()); Client = new(settings); - EventStore = new EsdbEventStore(Client); + EventStore = new KurrentDBEventStore(Client); _mongoContainer = new MongoDbBuilder().WithImage("mongo:8").Build(); await _mongoContainer.StartAsync(); var mongoSettings = MongoClientSettings.FromConnectionString(_mongoContainer.GetConnectionString()); diff --git a/src/Mongo/test/Eventuous.Tests.Projections.MongoDB/ProjectionTestBase.cs b/src/Mongo/test/Eventuous.Tests.Projections.MongoDB/ProjectionTestBase.cs index bbafbdf6d..2324d4251 100644 --- a/src/Mongo/test/Eventuous.Tests.Projections.MongoDB/ProjectionTestBase.cs +++ b/src/Mongo/test/Eventuous.Tests.Projections.MongoDB/ProjectionTestBase.cs @@ -1,4 +1,4 @@ -using Eventuous.EventStore.Subscriptions; +using Eventuous.KurrentDB.Subscriptions; using Eventuous.Projections.MongoDB; using Eventuous.Subscriptions; using Eventuous.Subscriptions.Checkpoints;