Skip to content

Managing sharding databases

Jon P Smith edited this page Apr 25, 2022 · 15 revisions

The AuthP library has a AuthPermissions.SupportCode project which contains a service called AccessDatabaseInformation. This can be used to alter the list of database information in the shardingsettings.json file.

This provides methods to:

  • ReadShardingSettingsFile - read the shardingsettings.json file - useful for showing all the content of the file.
  • GetDatabaseInformationByName(name) - read a specific database information. Used when editing / deleting an entry.
  • AddDatabaseInfoToJsonFile(info) - Adds a new database information to the shardingsettings.json file.
  • UpdateDatabaseInfoToJsonFile(info) - Updates the database information with the given Name.
  • RemoveDatabaseInfoToJsonFileAsync(name) - Removes the database information with the given Name.

This is designed to work with both development and production.

NOTE: You need to manually register this service as its not part of the AuthP setup. See this code from the application's Program class.

//manually add services from the AuthPermissions.SupportCode project
builder.Services.AddTransient<IAccessDatabaseInformation, AccessDatabaseInformation>();

Example of using this service

You can see the AccessDatabaseInformation running in the Example6.MvcWebApp.Sharding web application. Log in as an application admin user and click the Auth Admin -> List database info. See the screenshot below:

List database information

The code can be found in the ShardingController class.

Articles / Videos

Concepts

Setup

Usage

Admin

SupportCode

Clone this wiki locally