Skip to content
This repository was archived by the owner on Dec 11, 2024. It is now read-only.

Commit 51e5a16

Browse files
authored
Hotfix/7.0.4 (#110)
* db conn aclaration * exception logging & builder * docs * wait for data generation * currentHolder with initial ctor * xmldocs * wait for default tenant * xmldocs * formatting * logging improved * xmldocs * xmldocs * method detection standardized * xmldocs * method detections * xmldocs * description and min version * fix logging of errors array * cherrypick-errors fixed * dependency fix * test fix * correlation holder is injected, must not contain more public ctors * build triggers adapted * master -> main
1 parent 3c7d4e5 commit 51e5a16

39 files changed

+231
-62
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Backend.Fx.AspNetCore.Mvc | 2.0 | [![NuGet](https://img.shields.io/nuget/v/Backe
1515
Backend.Fx.NetCore | 1.3 | [![NuGet](https://img.shields.io/nuget/v/Backend.Fx.NetCore.svg)](https://www.nuget.org/packages/Backend.Fx.NetCore)
1616

1717
## What does "opinionated" mean?
18-
You get vendor locked to a set of abstractions, like my DDD building blocks and some architecture [patterns](https://github.com/marcwittke/Backend.Fx/tree/master/src/abstractions/Backend.Fx/Patterns) defined as interfaces
18+
You get vendor locked to a set of abstractions, like my DDD building blocks and some architecture [patterns](https://github.com/marcwittke/Backend.Fx/tree/main/src/abstractions/Backend.Fx/Patterns) defined as interfaces
1919

2020
## Less opinonated, but already provided as pluggable implementations of patterns
2121

build/Build.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class Build : NukeBuild
9292
.DependsOn(Pack)
9393
.Executes(() =>
9494
{
95-
bool pushToNuget = GitRepository.Branch == "master";
95+
bool pushToNuget = GitRepository.Branch == "main";
9696

9797
foreach (var nupkg in ArtifactsDirectory.GlobFiles("*.nupkg"))
9898
{

src/abstractions/Backend.Fx/Environment/Authentication/CurrentIdentityHolder.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ namespace Backend.Fx.Environment.Authentication
55
{
66
public class CurrentIdentityHolder : CurrentTHolder<IIdentity>
77
{
8+
public CurrentIdentityHolder()
9+
{ }
10+
11+
private CurrentIdentityHolder(IIdentity initial) : base(initial)
12+
{ }
13+
814
public override IIdentity ProvideInstance()
915
{
1016
return new AnonymousIdentity();
@@ -28,9 +34,7 @@ public static ICurrentTHolder<IIdentity> CreateSystem()
2834

2935
public static ICurrentTHolder<IIdentity> Create(IIdentity identity)
3036
{
31-
var currentIdentityHolder = new CurrentIdentityHolder();
32-
currentIdentityHolder.ReplaceCurrent(identity);
33-
return currentIdentityHolder;
37+
return new CurrentIdentityHolder(identity);
3438
}
3539
}
3640
}

src/abstractions/Backend.Fx/Environment/MultiTenancy/CurrentTenantIdHolder.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,21 @@ namespace Backend.Fx.Environment.MultiTenancy
44
{
55
public class CurrentTenantIdHolder : CurrentTHolder<TenantId>
66
{
7+
public CurrentTenantIdHolder()
8+
{ }
9+
10+
private CurrentTenantIdHolder(TenantId initial) : base(initial)
11+
{ }
12+
713
public static CurrentTenantIdHolder Create(int tenantId)
814
{
9-
var instance = new CurrentTenantIdHolder();
10-
instance.ReplaceCurrent(new TenantId(tenantId));
15+
var instance = new CurrentTenantIdHolder((TenantId)tenantId);
1116
return instance;
1217
}
1318

1419
public static CurrentTenantIdHolder Create(TenantId tenantId)
1520
{
16-
var instance = new CurrentTenantIdHolder();
17-
instance.ReplaceCurrent(tenantId);
21+
var instance = new CurrentTenantIdHolder(tenantId);
1822
return instance;
1923
}
2024

src/abstractions/Backend.Fx/Environment/MultiTenancy/ITenantIdProvider.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
namespace Backend.Fx.Environment.MultiTenancy
22
{
33
/// <summary>
4-
/// By means of this instance, other services gain insight about all active tenants. This is useful, when for example a job
4+
/// By means of this instance, the IBackendFxApplication gains insight about all active tenants. This is required, when for example a job
55
/// should be executed for all tenants or data should be generated for all tenants during startup.
6+
/// The <see cref="ITenantService"/> can provide such implementation, but this can only be done in process. When the tenant service is
7+
/// running in another process, the implementation must be done using a suitable remoting technology.
68
/// </summary>
79
public interface ITenantIdProvider
810
{

src/abstractions/Backend.Fx/Environment/MultiTenancy/SingleTenantApplication.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public class SingleTenantApplication : TenantApplication, IBackendFxApplication
1313
private readonly bool _isDemoTenant;
1414
private readonly ITenantService _tenantService;
1515
private readonly IBackendFxApplication _application;
16+
private readonly ManualResetEventSlim _defaultTenantEnsured = new ManualResetEventSlim(false);
1617

1718
public SingleTenantApplication(bool isDemoTenant, ITenantService tenantService, IBackendFxApplication application) : base(application)
1819
{
@@ -38,7 +39,7 @@ public void Dispose()
3839

3940
public bool WaitForBoot(int timeoutMilliSeconds = int.MaxValue, CancellationToken cancellationToken = default)
4041
{
41-
return _application.WaitForBoot(timeoutMilliSeconds, cancellationToken);
42+
return _defaultTenantEnsured.Wait(timeoutMilliSeconds, cancellationToken);
4243
}
4344

4445
public async Task Boot(CancellationToken cancellationToken = default)
@@ -50,6 +51,8 @@ public async Task Boot(CancellationToken cancellationToken = default)
5051
Logger.Info($"Ensuring existence of single tenant");
5152
TenantId = _tenantService.GetActiveTenants().SingleOrDefault()?.GetTenantId()
5253
?? _tenantService.CreateTenant("Single Tenant", "This application runs in single tenant mode", _isDemoTenant);
54+
55+
_defaultTenantEnsured.Set();
5356
}
5457
}
5558
}

src/abstractions/Backend.Fx/Environment/Persistence/DbConnectionOperationDecorator.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ public void Complete()
3838
public void Cancel()
3939
{
4040
Operation.Cancel();
41+
Logger.Debug("Closing database connection");
42+
DbConnection.Close();
43+
_connectionLifetimeLogger?.Dispose();
44+
45+
// note: we do not dispose the DbConnection here, because we did not instantiate it. Disposing is always up to the creator of
46+
// the instance, that is in this case the injection container.
4147
}
4248
}
4349
}

src/abstractions/Backend.Fx/Exceptions/ClientException.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,19 @@ public ClientException()
1212
{
1313
}
1414

15+
/// <param name="message">When using one of the middlewares in Backend.Fx.AspNetCore.ErrorHandling, the message is not sent
16+
/// to the client to not provide internal details to an attacker. Write the exception message with a developer in mind, since
17+
/// the application log will contain the message. To provide the user with functional feedback to correct their input, use
18+
/// the AddError(s) overloads.</param>
1519
public ClientException(string message)
1620
: base(message)
1721
{
1822
}
1923

24+
/// <param name="message">When using one of the middlewares in Backend.Fx.AspNetCore.ErrorHandling, the message is not sent
25+
/// to the client to not provide internal details to an attacker. Write the exception message with a developer in mind, since
26+
/// the application log will contain the message. To provide the user with functional feedback to correct their input, use
27+
/// the AddError(s) overloads.</param>
2028
public ClientException(string message, Exception innerException)
2129
: base(message, innerException)
2230
{
@@ -48,6 +56,16 @@ public override string ToString()
4856
return string.Join(System.Environment.NewLine,
4957
new[] {message, Errors.ToString(), innerException, StackTrace}.Where(s => s != null));
5058
}
59+
60+
/// <summary>
61+
/// Used to build an <see cref="ClientException"/> with multiple possible error messages. The builder will throw on disposal
62+
/// when at least one error was added. Using the AddIf methods is quite comfortable when there are several criteria to be validated
63+
/// before executing a business case.
64+
/// </summary>
65+
public static IExceptionBuilder UseBuilder()
66+
{
67+
return new ExceptionBuilder<ClientException>();
68+
}
5169
}
5270

5371
public static class ClientExceptionEx

src/abstractions/Backend.Fx/Exceptions/ConflictedException.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,16 @@ public ConflictedException()
99
{
1010
}
1111

12+
/// <inheritdoc />
1213
public ConflictedException(string message)
1314
: base(message)
1415
{
1516
}
1617

18+
/// <inheritdoc />
1719
public ConflictedException(string message, Exception innerException)
1820
: base(message, innerException)
1921
{
2022
}
21-
22-
public static IExceptionBuilder UseBuilder()
23-
{
24-
return new ExceptionBuilder<ConflictedException>();
25-
}
2623
}
2724
}

src/abstractions/Backend.Fx/Exceptions/ForbiddenException.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,16 @@ public ForbiddenException()
99
{
1010
}
1111

12+
/// <inheritdoc />
1213
public ForbiddenException(string message)
1314
: base(message)
1415
{
1516
}
1617

18+
/// <inheritdoc />
1719
public ForbiddenException(string message, Exception innerException)
1820
: base(message, innerException)
1921
{
2022
}
21-
22-
public static IExceptionBuilder UseBuilder()
23-
{
24-
return new ExceptionBuilder<ForbiddenException>();
25-
}
2623
}
2724
}

0 commit comments

Comments
 (0)