-
Notifications
You must be signed in to change notification settings - Fork 160
Managing sharding databases
Since AuthP version 6 when you set the AuthPermissionsOptions's TenantType
and added SetupMultiTenantSharding
method to register that the multi-tenant is using sharding, then the SetupMultiTenantSharding
will register a called IGetSetShardingEntries that provides ways to read / change the sharding entries, and other support methods. The typical things you might to do are:
- Managing the sharding entries
- Reading the connection string names
- List the databases and their tenants
The GetAllShardingEntries
method reads the information in the sharding entries. This is used internally but is also useful for the admin user to see what the sharding entries. The screenshot below comes from Example6.MvcWebApp.Sharding
web application. If you log in as an application admin user and click the Auth Admin -> List database info.
The code for these can be found in the ShardingController
class of Example6 and Example7
These are simple to understand. They alter the sharding entries containing all the sharding entries.
-
AddNewShardingEntry(info)
- Adds a new sharding entry to the sharding entries. -
UpdateShardingEntry(info)
- Updates the sharding entry with the givenName
. -
RemoveShardingEntry(name)
- Removes the sharding entry with the givenName
.
When to create a sharding tenant, then you need to get the connection strings that provide access to the database server to use - see this example of creating a new tenant. The IGetSetShardingEntries
service provides a method called GetConnectionStringNames
, which have one connection string (one single server), or many connection strings if you have multiple database servers.
NOTE: The mode (hybrid or sharding-only) you will affect what connection string names are shown - see this section about modes for more detail.
In a hybrid multi-tenant application databases can have multiple tenants in one database. This means that a list of sharding entries doesn't provide all the information you need when changing sharding entries. Therefore the IGetSetShardingEntries
service provides a method called GetDatabaseInfoNamesWithTenantNamesAsync
which shows each sharding with a list of tenants in each database.
NOTE: This method isn't very useful if you using the sharding-only mode, because each sharding entry has one database, so the "list sharding entries" is a better list.
- Intro to multi-tenants (ASP.NET video)
- Articles in date order:
- 0. Improved Roles/Permissions
- 1. Setting up the database
- 2. Admin: adding users and tenants
- 3. Versioning your app
- 4. Hierarchical multi-tenant
- 5. Advanced technique with claims
- 6. Sharding multi-tenant setup
- 7. Three ways to add new users
- 8. The design of the sharding data
- 9. Down for maintenance article
- 10: Three ways to refresh claims
- 11. Features of Multilingual service
- 12. Custom databases - Part1
- Videos (old)
- Authentication explained
- Permissions explained
- Roles explained
- AuthUser explained
- Multi tenant explained
- Sharding explained
- How AuthP handles sharding
- How AuthP handles errors
- Languages & cultures explained
- JWT Token refresh explained
- Setup Permissions
- Setup Authentication
- Startup code
- Setup the custom database feature
- JWT Token configuration
- Multi tenant configuration
- Using Permissions
- Using JWT Tokens
- Creating a multi-tenant app
- Supporting multiple languages
- Unit Test your AuthP app