Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ jobs:
uses: actions/checkout@v5
with:
fetch-depth: 0
-
name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: |
10.0
-
name: Login to Docker Hub
if: ${{ github.event.pull_request.head.repo.fork == false }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_TOKEN }}
-
name: Run tests
run: dotnet test --framework net10.0
Expand Down
8 changes: 3 additions & 5 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<PropertyGroup Label="Package versions for .NET 10" Condition="'$(TargetFramework)' == 'net10.0'">
<MicrosoftTestHostVer>10.0.0-rc.2.25502.107</MicrosoftTestHostVer>
<MicrosoftExtensionsVer>10.0.0-rc.2.25502.107</MicrosoftExtensionsVer>
<MicrosoftTestHostVer>10.0.0</MicrosoftTestHostVer>
<MicrosoftExtensionsVer>10.0.0</MicrosoftExtensionsVer>
</PropertyGroup>
<PropertyGroup Label="Package versions for .NET 9" Condition="'$(TargetFramework)' == 'net9.0'">
<MicrosoftTestHostVer>9.0.10</MicrosoftTestHostVer>
Expand Down Expand Up @@ -38,11 +38,9 @@
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageVersion Include="Shouldly" Version="4.2.1" />
<PackageVersion Include="System.Diagnostics.DiagnosticSource" Version="$(MicrosoftExtensionsVer)" />
<PackageVersion Include="System.Linq.AsyncEnumerable" Version="10.0.0" />
<PackageVersion Include="System.Reactive" Version="6.0.1" />
<PackageVersion Include="System.Linq.Async" Version="6.0.3" />
<PackageVersion Include="OpenTelemetry.Extensions.Hosting" Version="1.13.1" />
<PackageVersion Include="EventStore.Client.Grpc.PersistentSubscriptions" Version="23.3.9" />
<PackageVersion Include="EventStore.Client.Grpc.Streams" Version="23.3.9" />
<PackageVersion Include="MongoDB.Driver" Version="3.4.0" />
<PackageVersion Include="Google.Cloud.PubSub.V1" Version="3.19.0" />
<PackageVersion Include="Confluent.Kafka" Version="2.6.1" />
Expand Down
2 changes: 1 addition & 1 deletion samples/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>preview</LangVersion>
Expand Down
12 changes: 6 additions & 6 deletions samples/esdb/Bookings.Domain/Bookings/BookingState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ public BookingState() {

static BookingState HandlePayment(BookingState state, V1.PaymentRecorded e)
=> state with {
Outstanding = new Money { Amount = e.Outstanding, Currency = e.Currency },
Payments = state.Payments.Add(new PaymentRecord(e.PaymentId, new Money(e.PaidAmount, e.Currency)))
Outstanding = new() { Amount = e.Outstanding, Currency = e.Currency },
Payments = state.Payments.Add(new(e.PaymentId, new(e.PaidAmount, e.Currency)))
};

static BookingState HandleBooked(BookingState state, V1.RoomBooked booked)
=> state with {
RoomId = new RoomId(booked.RoomId),
Period = new StayPeriod(booked.CheckInDate, booked.CheckOutDate),
RoomId = new(booked.RoomId),
Period = new(booked.CheckInDate, booked.CheckOutDate),
GuestId = booked.GuestId,
Price = new Money { Amount = booked.BookingPrice, Currency = booked.Currency },
Outstanding = new Money { Amount = booked.OutstandingAmount, Currency = booked.Currency }
Price = new() { Amount = booked.BookingPrice, Currency = booked.Currency },
Outstanding = new() { Amount = booked.OutstandingAmount, Currency = booked.Currency }
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public CommandService(IEventStore store) : base(store) {
On<PaymentCommands.RecordPayment>()
.InState(ExpectedState.New)
.GetId(cmd => new(cmd.PaymentId))
.Act((payment, cmd) => payment.ProcessPayment(cmd.BookingId, new Money(cmd.Amount, cmd.Currency), cmd.Method, cmd.Provider));
.Act((payment, cmd) => payment.ProcessPayment(cmd.BookingId, new(cmd.Amount, cmd.Currency), cmd.Method, cmd.Provider));
}
}

Expand Down
2 changes: 1 addition & 1 deletion samples/esdb/Bookings.Payments/Bookings.Payments.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<ItemGroup>
<ProjectReference Include="$(SrcRoot)\Extensions\src\Eventuous.Extensions.AspNetCore\Eventuous.Extensions.AspNetCore.csproj"/>
<ProjectReference Include="$(SrcRoot)\Extensions\src\Eventuous.Extensions.DependencyInjection\Eventuous.Extensions.DependencyInjection.csproj"/>
<ProjectReference Include="..\..\..\src\KurrentDb\src\Eventuous.KurrentDB\Eventuous.KurrentDB.csproj" />
<ProjectReference Include="$(SrcRoot)\KurrentDB\src\Eventuous.KurrentDB\Eventuous.KurrentDB.csproj" />
<ProjectReference Include="$(SrcRoot)\Mongo\src\Eventuous.Projections.MongoDB\Eventuous.Projections.MongoDB.csproj"/>
<ProjectReference Include="$(SrcRoot)\Diagnostics\src\Eventuous.Diagnostics.OpenTelemetry\Eventuous.Diagnostics.OpenTelemetry.csproj"/>
<ProjectReference Include="$(SrcRoot)\Gateway\src\Eventuous.Gateway\Eventuous.Gateway.csproj"/>
Expand Down
6 changes: 3 additions & 3 deletions samples/esdb/Bookings.Payments/Integration/Payments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ namespace Bookings.Payments.Integration;
public static class PaymentsGateway {
static readonly StreamName Stream = new("PaymentsIntegration");

public static ValueTask<GatewayMessage<KurrentDbProduceOptions>[]> Transform(IMessageConsumeContext original) {
public static ValueTask<GatewayMessage<KurrentDBProduceOptions>[]> Transform(IMessageConsumeContext original) {
var result = original.Message is PaymentEvents.PaymentRecorded evt
? new GatewayMessage<KurrentDbProduceOptions>(
? new GatewayMessage<KurrentDBProduceOptions>(
Stream,
new BookingPaymentRecorded(original.Stream.GetId(), evt.BookingId, evt.Amount, evt.Currency),
new(),
new()
)
: null;
GatewayMessage<KurrentDbProduceOptions>[] gatewayMessages = result != null ? [result] : [];
GatewayMessage<KurrentDBProduceOptions>[] gatewayMessages = result != null ? [result] : [];
return ValueTask.FromResult(gatewayMessages);
}
}
Expand Down
66 changes: 34 additions & 32 deletions samples/esdb/Bookings.Payments/Registrations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,40 +14,42 @@
namespace Bookings.Payments;

public static class Registrations {
public static void AddServices(this IServiceCollection services, IConfiguration configuration) {
services.AddKurrentDBClient(configuration["EventStore:ConnectionString"]!);
services.AddEventStore<KurrentDBEventStore>();
services.AddCommandService<CommandService, PaymentState>();
services.AddSingleton(Mongo.ConfigureMongo(configuration));
services.AddCheckpointStore<MongoCheckpointStore>();
services.AddProducer<KurrentDbProducer>();
extension(IServiceCollection services) {
public void AddServices(IConfiguration configuration) {
services.AddKurrentDBClient(configuration["EventStore:ConnectionString"]!);
services.AddEventStore<KurrentDBEventStore>();
services.AddCommandService<CommandService, PaymentState>();
services.AddSingleton(Mongo.ConfigureMongo(configuration));
services.AddCheckpointStore<MongoCheckpointStore>();
services.AddProducer<KurrentDBProducer>();

services
.AddGateway<AllStreamSubscription, AllStreamSubscriptionOptions, KurrentDbProducer, KurrentDbProduceOptions>(
"IntegrationSubscription",
PaymentsGateway.Transform
);
}
services
.AddGateway<AllStreamSubscription, AllStreamSubscriptionOptions, KurrentDBProducer, KurrentDBProduceOptions>(
"IntegrationSubscription",
PaymentsGateway.Transform
);
}

public static void AddTelemetry(this IServiceCollection services) {
services.AddOpenTelemetry()
.WithMetrics(
builder => builder
.AddAspNetCoreInstrumentation()
.AddEventuous()
.AddEventuousSubscriptions()
.AddPrometheusExporter()
);
public void AddTelemetry() {
services.AddOpenTelemetry()
.WithMetrics(
builder => builder
.AddAspNetCoreInstrumentation()
.AddEventuous()
.AddEventuousSubscriptions()
.AddPrometheusExporter()
);

services.AddOpenTelemetry()
.WithTracing(
builder => builder
.AddAspNetCoreInstrumentation()
.AddGrpcClientInstrumentation()
.AddEventuousTracing()
.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("payments"))
.SetSampler(new AlwaysOnSampler())
.AddZipkinExporter()
);
services.AddOpenTelemetry()
.WithTracing(
builder => builder
.AddAspNetCoreInstrumentation()
.AddGrpcClientInstrumentation()
.AddEventuousTracing()
.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("payments"))
.SetSampler(new AlwaysOnSampler())
.AddZipkinExporter()
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public MyBookingsProjection(IMongoDatabase database) : base(database) {
.UpdateFromContext((ctx, update) =>
update.AddToSet(
x => x.Bookings,
new MyBookings.Booking(ctx.Stream.GetId(),
new(ctx.Stream.GetId(),
ctx.Message.CheckInDate,
ctx.Message.CheckOutDate,
ctx.Message.BookingPrice
Expand Down
2 changes: 1 addition & 1 deletion samples/esdb/Bookings/Bookings.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(SrcRoot)\Diagnostics\src\Eventuous.Diagnostics.Logging\Eventuous.Diagnostics.Logging.csproj"/>
<ProjectReference Include="..\..\..\src\KurrentDb\src\Eventuous.KurrentDB\Eventuous.KurrentDB.csproj" />
<ProjectReference Include="$(SrcRoot)\KurrentDB\src\Eventuous.KurrentDB\Eventuous.KurrentDB.csproj" />
<ProjectReference Include="$(SrcRoot)\Experimental\src\Eventuous.Spyglass\Eventuous.Spyglass.csproj"/>
<ProjectReference Include="$(SrcRoot)\Extensions\src\Eventuous.Extensions.DependencyInjection\Eventuous.Extensions.DependencyInjection.csproj"/>
<ProjectReference Include="$(SrcRoot)\Mongo\src\Eventuous.Projections.MongoDB\Eventuous.Projections.MongoDB.csproj"/>
Expand Down
2 changes: 1 addition & 1 deletion samples/esdb/Bookings/Infrastructure/Mongo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static IMongoDatabase ConfigureMongo(IConfiguration configuration) {
var settings = MongoClientSettings.FromConnectionString(config!.ConnectionString);

if (config is { User: not null, Password: not null }) {
settings.Credential = new MongoCredential(
settings.Credential = new(
null,
new MongoInternalIdentity("admin", config.User),
new PasswordEvidence(config.Password)
Expand Down
2 changes: 1 addition & 1 deletion samples/esdb/Bookings/Registrations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void AddEventuous(IConfiguration configuration) {
services.AddCommandService<BookingsCommandService, BookingState>();

services.AddSingleton<Services.IsRoomAvailable>((_, _) => new(true));
services.AddSingleton<Services.ConvertCurrency>((from, currency) => new Money(from.Amount * 2, currency));
services.AddSingleton<Services.ConvertCurrency>((from, currency) => new(from.Amount * 2, currency));

services.AddSingleton(Mongo.ConfigureMongo(configuration));

Expand Down
2 changes: 1 addition & 1 deletion samples/postgres/Bookings.Payments/Integration/Payments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static ValueTask<GatewayMessage<RabbitMqProduceOptions>[]> Transform(IMes
? new GatewayMessage<RabbitMqProduceOptions>(
Stream,
new BookingPaymentRecorded(original.Stream.GetId(), evt.BookingId, evt.Amount, evt.Currency),
new Metadata(),
new(),
ProduceOptions
)
: null;
Expand Down
2 changes: 1 addition & 1 deletion samples/postgres/Bookings.Payments/Registrations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Bookings.Payments;
public static class Registrations {
public static void AddEventuous(this IServiceCollection services, IConfiguration configuration) {
var connectionFactory = new ConnectionFactory {
Uri = new Uri(configuration["RabbitMq:ConnectionString"]!),
Uri = new(configuration["RabbitMq:ConnectionString"]!),
DispatchConsumersAsync = true
};
services.AddSingleton(connectionFactory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public MyBookingsProjection(IMongoDatabase database) : base(database) {
.UpdateFromContext((ctx, update) =>
update.AddToSet(
x => x.Bookings,
new MyBookings.Booking(ctx.Stream.GetId(),
new(ctx.Stream.GetId(),
ctx.Message.CheckInDate,
ctx.Message.CheckOutDate,
ctx.Message.BookingPrice
Expand Down
2 changes: 1 addition & 1 deletion samples/postgres/Bookings/Registrations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static void AddEventuous(this IServiceCollection services, IConfiguration
services.AddSingleton<Services.IsRoomAvailable>((_, _) => new(true));

services.AddSingleton<Services.ConvertCurrency>(
(from, currency) => new Money(from.Amount * 2, currency)
(from, currency) => new(from.Amount * 2, currency)
);

services.AddSingleton(Mongo.ConfigureMongo(configuration));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,11 @@ static void Generate(SourceProductionContext context, string assemblyName, Immut

foreach (var m in distinct) {
// Prefer passing the explicit name when we have it, so runtime reflection is avoided
if (!string.IsNullOrEmpty(m.EventTypeName)) {
sb.AppendLine($" mapper.AddType(typeof({m.FullyQualifiedType}), \"{EscapeString(m.EventTypeName)}\");");
}
else {
sb.AppendLine($" mapper.AddType(typeof({m.FullyQualifiedType}));");
}
sb.AppendLine(
!string.IsNullOrEmpty(m.EventTypeName)
? $" mapper.AddType(typeof({m.FullyQualifiedType}), \"{EscapeString(m.EventTypeName)}\");"
: $" mapper.AddType(typeof({m.FullyQualifiedType}));"
);
}

sb.AppendLine(" }");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context) {

static bool IsPotentialUsage(SyntaxNode node, CancellationToken _) {
return node switch {
GenericNameSyntax { TypeArgumentList.Arguments.Count: 1 } g => g.Identifier.Text == "IMessageConsumeContext" || g.Identifier.Text == "On",
GenericNameSyntax { TypeArgumentList.Arguments.Count: 1 } g => g.Identifier.Text is "IMessageConsumeContext" or "On",
// handle qualified names like Eventuous.Subscriptions.Context.IMessageConsumeContext<T>
QualifiedNameSyntax { Right: GenericNameSyntax { TypeArgumentList.Arguments.Count: 1 } g2 } => g2.Identifier.Text == "IMessageConsumeContext",
// implicit: lambdas where parameter type is inferred to IMessageConsumeContext<T>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ IDefineAppendAmendment<TCommand> IDefineExecution<TCommand, TAggregate, TState>.
}

IDefineExecution<TCommand, TAggregate, TState> IDefineStore<TCommand, TAggregate, TState>.ResolveStore(Func<TCommand, IEventStore> resolveStore) {
Ensure.NotNull(resolveStore, nameof(resolveStore));
Ensure.NotNull(resolveStore);
_reader = resolveStore;
_writer = resolveStore;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,13 @@ RegisteredHandler<TState> Build() {
);

Func<TCommand, IEventWriter> DefaultResolveWriter() {
ArgumentNullException.ThrowIfNull(writer, nameof(writer));
ArgumentNullException.ThrowIfNull(writer);

return _ => writer;
}

Func<TCommand, IEventReader> DefaultResolveReader() {
ArgumentNullException.ThrowIfNull(reader, nameof(reader));
ArgumentNullException.ThrowIfNull(reader);

return _ => reader;
}
Expand Down
Loading
Loading