Skip to content

Commit

Permalink
Fix DI lifetimes
Browse files Browse the repository at this point in the history
  • Loading branch information
ThorstenThiel committed Oct 22, 2023
1 parent 101b938 commit 5198dcf
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/Fluss.HotChocolate/Fluss.HotChocolate.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0; net7.0; net6.0</TargetFrameworks>
<TargetFrameworks>net8.0; net7.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Fluss.PostgreSQL/Fluss.PostgreSQL.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0; net7.0; net6.0</TargetFrameworks>
<TargetFrameworks>net8.0; net7.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Fluss.PostgreSQL/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static IServiceCollection AddPostgresEventSourcingRepository(this IServic
}

return services
.AddScoped<IBaseEventRepository, Fluss.PostgreSQL.PostgreSQLEventRepository>()
.AddBaseEventRepository<PostgreSQLEventRepository>()
.AddFluentMigratorCore()
.ConfigureRunner(rb => rb
.AddPostgres()
Expand Down
2 changes: 1 addition & 1 deletion src/Fluss.Testing/Fluss.Testing.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0; net7.0; net6.0</TargetFrameworks>
<TargetFrameworks>net8.0; net7.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Fluss.UnitTest/Fluss.UnitTest.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0; net7.0; net6.0</TargetFrameworks>
<TargetFrameworks>net8.0; net7.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

Expand Down
6 changes: 3 additions & 3 deletions src/Fluss/Authentication/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ public static IServiceCollection AddPoliciesFrom(this IServiceCollection service

foreach (var policyType in policyTypes)
{
services = services
.AddScoped(policyType)
.AddScoped(sp => (Policy)sp.GetRequiredService(policyType));
services
.AddSingleton(policyType)
.AddSingleton(sp => (Policy)sp.GetRequiredService(policyType));
}

return services;
Expand Down
2 changes: 1 addition & 1 deletion src/Fluss/Fluss.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0; net7.0; net6.0</TargetFrameworks>
<TargetFrameworks>net8.0; net7.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PackageId>Fluss</PackageId>
Expand Down
2 changes: 1 addition & 1 deletion src/Fluss/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public static IServiceCollection AddUpcasters(this IServiceCollection services,

foreach (var upcaster in upcasters)
{
services.AddScoped(upcasterType, upcaster);
services.AddSingleton(upcasterType, upcaster);
}

return services.AddSingleton<EventUpcasterService>().AddSingleton<UpcasterSorter>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static IServiceCollection RegisterSideEffects(this IServiceCollection ser

foreach (var @class in implementingClasses)
{
services.AddScoped(typeof(SideEffect), @class);
services.AddSingleton(typeof(SideEffect), @class);
}

services.AddHostedService<SideEffectDispatcher>();
Expand Down
4 changes: 2 additions & 2 deletions src/Fluss/Validation/ValidationServiceCollectionExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ public static IServiceCollection AddValidationFrom(this IServiceCollection servi
sourceAssembly.GetTypes().Where(t => t.IsAssignableTo(aggregateValidatorType)).ToList();
foreach (var aggregateValidator in aggregateValidators)
{
services.AddScoped(aggregateValidatorType, aggregateValidator);
services.AddSingleton(aggregateValidatorType, aggregateValidator);
}

var eventValidatorType = typeof(EventValidator);
var eventValidators =
sourceAssembly.GetTypes().Where(t => t.IsAssignableTo(eventValidatorType)).ToList();
foreach (var eventValidator in eventValidators)
{
services.AddScoped(eventValidatorType, eventValidator);
services.AddSingleton(eventValidatorType, eventValidator);
}

services.AddSingleton<IRootValidator, RootValidator>();
Expand Down

0 comments on commit 5198dcf

Please sign in to comment.