Skip to content

Commit 782feda

Browse files
committed
Simplified a method name
1 parent e118459 commit 782feda

File tree

9 files changed

+74
-9
lines changed

9 files changed

+74
-9
lines changed

AuthPermissions.AspNetCore.sln

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example7.MvcWebApp.Sharding
5454
EndProject
5555
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example7.SingleLevelShardingOnly", "Example7.SingleLevelShardingOnly\Example7.SingleLevelShardingOnly.csproj", "{9ABE93FC-DE35-47E1-B5B3-27867E350933}"
5656
EndProject
57+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp.AuthP6Upgrade", "ConsoleApp.AuthP6Upgrade\ConsoleApp.AuthP6Upgrade.csproj", "{65A69729-B8E3-4F11-B88F-2AF1AFAB50F2}"
58+
EndProject
5759
Global
5860
GlobalSection(SolutionConfigurationPlatforms) = preSolution
5961
Debug|Any CPU = Debug|Any CPU
@@ -304,6 +306,18 @@ Global
304306
{9ABE93FC-DE35-47E1-B5B3-27867E350933}.Release|x64.Build.0 = Release|Any CPU
305307
{9ABE93FC-DE35-47E1-B5B3-27867E350933}.Release|x86.ActiveCfg = Release|Any CPU
306308
{9ABE93FC-DE35-47E1-B5B3-27867E350933}.Release|x86.Build.0 = Release|Any CPU
309+
{65A69729-B8E3-4F11-B88F-2AF1AFAB50F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
310+
{65A69729-B8E3-4F11-B88F-2AF1AFAB50F2}.Debug|Any CPU.Build.0 = Debug|Any CPU
311+
{65A69729-B8E3-4F11-B88F-2AF1AFAB50F2}.Debug|x64.ActiveCfg = Debug|Any CPU
312+
{65A69729-B8E3-4F11-B88F-2AF1AFAB50F2}.Debug|x64.Build.0 = Debug|Any CPU
313+
{65A69729-B8E3-4F11-B88F-2AF1AFAB50F2}.Debug|x86.ActiveCfg = Debug|Any CPU
314+
{65A69729-B8E3-4F11-B88F-2AF1AFAB50F2}.Debug|x86.Build.0 = Debug|Any CPU
315+
{65A69729-B8E3-4F11-B88F-2AF1AFAB50F2}.Release|Any CPU.ActiveCfg = Release|Any CPU
316+
{65A69729-B8E3-4F11-B88F-2AF1AFAB50F2}.Release|Any CPU.Build.0 = Release|Any CPU
317+
{65A69729-B8E3-4F11-B88F-2AF1AFAB50F2}.Release|x64.ActiveCfg = Release|Any CPU
318+
{65A69729-B8E3-4F11-B88F-2AF1AFAB50F2}.Release|x64.Build.0 = Release|Any CPU
319+
{65A69729-B8E3-4F11-B88F-2AF1AFAB50F2}.Release|x86.ActiveCfg = Release|Any CPU
320+
{65A69729-B8E3-4F11-B88F-2AF1AFAB50F2}.Release|x86.Build.0 = Release|Any CPU
307321
EndGlobalSection
308322
GlobalSection(SolutionProperties) = preSolution
309323
HideSolutionNode = FALSE

AuthPermissions.AspNetCore/ShardingServices/GetSetShardingEntriesFileStoreCache.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ public List<string> GetConnectionStringNames()
185185
/// </summary>
186186
/// <returns>List of all the sharding entries names with the tenants using that database data name
187187
/// NOTE: The hasOwnDb is true for a database containing a single database, false for multiple tenant database and null if empty</returns>
188-
public async Task<List<(string shardingName, bool? hasOwnDb, List<string> tenantNames)>> GetDatabaseInfoNamesWithTenantNamesAsync()
188+
public async Task<List<(string shardingName, bool? hasOwnDb, List<string> tenantNames)>> GetShardingsWithTenantNamesAsync()
189189
{
190190
var nameAndConnectionName = await _authDbContext.Tenants
191191
.Select(x => new { ConnectionName = x.DatabaseInfoName, x })

AuthPermissions.AspNetCore/ShardingServices/IGetSetShardingEntries.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public interface IGetSetShardingEntries
6969
/// </summary>
7070
/// <returns>List of all the database info names with the tenants (and whether its sharding) within that database data name
7171
/// NOTE: The hasOwnDb is true for a database containing a single database, false for multiple tenant database and null if empty</returns>
72-
Task<List<(string shardingName, bool? hasOwnDb, List<string> tenantNames)>> GetDatabaseInfoNamesWithTenantNamesAsync();
72+
Task<List<(string shardingName, bool? hasOwnDb, List<string> tenantNames)>> GetShardingsWithTenantNamesAsync();
7373

7474
/// <summary>
7575
/// This will provide the connection string for the entry with the given database info name

AuthPermissions.SupportCode/DemoGetDatabaseForNewTenant.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public async Task<IStatusGeneric<Tenant>> FindOrCreateDatabaseAsync(Tenant tenan
5151
var status = new StatusGenericLocalizer<Tenant>(_localizeDefault);
5252

5353
//This gets the databases with the info on whether the database is available
54-
var dbsWithUsers = await _shardingService.GetDatabaseInfoNamesWithTenantNamesAsync();
54+
var dbsWithUsers = await _shardingService.GetShardingsWithTenantNamesAsync();
5555

5656
var foundDatabaseInfoName = hasOwnDb
5757
? // this will find the first empty database

Example6.MvcWebApp.Sharding/Controllers/TenantController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public async Task<IActionResult> Index(string message)
4040
[HasPermission(Example6Permissions.ListDbsWithTenants)]
4141
public async Task<IActionResult> ListDatabases([FromServices] IGetSetShardingEntries shardingService)
4242
{
43-
var connections = await shardingService.GetDatabaseInfoNamesWithTenantNamesAsync();
43+
var connections = await shardingService.GetShardingsWithTenantNamesAsync();
4444

4545
return View(connections);
4646
}

Example7.MvcWebApp.ShardingOnly/Controllers/TenantController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public async Task<IActionResult> Index(string message)
3838
[HasPermission(Example7Permissions.ListDbsWithTenants)]
3939
public async Task<IActionResult> ListDatabases([FromServices] IGetSetShardingEntries shardingService)
4040
{
41-
var connections = await shardingService.GetDatabaseInfoNamesWithTenantNamesAsync();
41+
var connections = await shardingService.GetShardingsWithTenantNamesAsync();
4242

4343
return View(connections);
4444
}

Test/StubClasses/StubGetSetShardingEntries.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public string FormConnectionString(string databaseInfoName)
126126
};
127127
}
128128

129-
public Task<List<(string shardingName, bool? hasOwnDb, List<string> tenantNames)>> GetDatabaseInfoNamesWithTenantNamesAsync()
129+
public Task<List<(string shardingName, bool? hasOwnDb, List<string> tenantNames)>> GetShardingsWithTenantNamesAsync()
130130
{
131131
return Task.FromResult(new List<(string key, bool? hasOwnDb, List<string> tenantNames)>
132132
{

Test/UnitTests/TestSharding/TestGetSetShardingEntriesFileStoreCache.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ public async Task TestQueryTenantsSingle()
477477
setup.AuthDbContext.ChangeTracker.Clear();
478478

479479
//ATTEMPT
480-
var list = await setup.Service.GetDatabaseInfoNamesWithTenantNamesAsync();
480+
var list = await setup.Service.GetShardingsWithTenantNamesAsync();
481481

482482
//VERIFY
483483
list.ShouldEqual(new List<(string databaseName, bool? hasOwnDb, List<string> tenantNames)>

UpdateToVersion6.md

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,62 @@
11
# Updating your code from AuthPermissions.AspNetCore 5.* to 6.0
22

3-
Version 6.0.0 of the AuthPermissions.AspNetCore library (shortened to **AuthP** from now on) contains improved sharding features, but they contain **BREAKING CHANGES**. There are lot of small and obvious changes, but only in AuthP's sharding features.
3+
Version 6.0.0 of the AuthPermissions.AspNetCore library (shortened to **AuthP** from now on) contains improved sharding features, but they contain **BREAKING CHANGES**. These breaking changes came about because of a limitation found in the ASP.NET Core `IOptions` feature (see this section ????). These changes ONLY EFFECT multi-tenant applications that use sharding, i.e. you have the `SetupMultiTenantSharding` extension method in your AuthP registration code.
4+
5+
However, when I was working on the data that links tenants to databases (now called _sharding entries_) I found my previous code didn't use _nice names_. For instance:
6+
7+
- The name of a class, method, etc didn't match what it was used for. For instance the class that links a tenant to a database was called `DatabaseInformation`, but its name is now its called `ShardingEntry`.
8+
- Some method names were too long. For instance the method that updated a `ShardingEntry` was called `UpdateDatabaseInfoToShardingInformation` and now called `UpdateShardingEntry`.
9+
10+
Of course this creates more breaking changes, but the code will be easier to understand. Also on upgrading to AuthP 6 it will be very obvious, as each change will become an error.
411

512
## TABLE OF CONTENT
613

7-
1.
14+
1. Changing to the new IGetSetShardingEntries service.
15+
2. Updating the IGetSetShardingEntries method names
16+
3. Make sure that distributed FileStore Cache is registered
17+
4. Once it complies and **before you run your application**
18+
- Move your sharding entries from the json file to the distributed FileStore Cache
819

920
The subsections below the items listed in the table of content.
1021

22+
## 1. Changing to the new [IGetSetShardingEntries](https://github.com/JonPSmith/AuthPermissions.AspNetCore/blob/main/AuthPermissions.AspNetCore/ShardingServices/IGetSetShardingEntries.cs) service
23+
24+
Before AuthP version 6 you had two services called `IAccessDatabaseInformationVer5` and `IShardingConnections`. Now you have one service called `IGetSetShardingEntries` that contains all the methods, properties, etc. that the two services it replaces.
25+
26+
| Old name | new name | Notes |
27+
| ----------------- | ------------- | ----- |
28+
| `IAccessDatabaseInformationVer5` | `IGetSetShardingEntries` | I use `shardingService` |
29+
| `IShardingConnections` | `IGetSetShardingEntries` | I use `shardingService` |
30+
31+
The other big change is `IGetSetShardingEntries` changes the name of a class
32+
33+
| Old name | new name | Notes |
34+
| ----------------- | ------------- | ----- |
35+
| `DatabaseInformation` | `ShardingEntry` | |
36+
37+
## 2. Updating the IGetSetShardingEntries method names
38+
39+
The table below gives the old and new.
40+
| Old name | new name | Notes |
41+
| ----------------- | ------------- | ----- |
42+
| `ReadAllShardingInformation` | `GetAllShardingEntries` | |
43+
| `GetDatabaseInformationByName` | `GetSingleShardingEntry` | |
44+
| `AddDatabaseInfoToShardingInformation` | `AddNewShardingEntry` | |
45+
| `UpdateDatabaseInfoToShardingInformation` | `UpdateShardingEntry` | |
46+
| `RemoveDatabaseInfoFromShardingInformationAsync` | `RemoveShardingEntry` | |
47+
| `GetAllPossibleShardingData` | `GetAllShardingEntries` | |
48+
| `GetDatabaseInfoNamesWithTenantNamesAsync` | `GetShardingsWithTenantNamesAsync` | |
49+
50+
A properly that has been simplified
51+
| Old name | new name | Notes |
52+
| ----------------- | ------------- | ----- |
53+
| `ShardingDatabaseProviders.Keys.ToArray()` | `PossibleDatabaseProviders()` | |
54+
55+
Other methods that haven't changed are listed below
56+
| Old name | new name | Notes |
57+
| ----------------- | ------------- | ----- |
58+
| `GetConnectionStringNames` | `GetConnectionStringNames` | see note1 |
59+
60+
Note1
61+
1162
END

0 commit comments

Comments
 (0)