We have developed several example solutions on our GitHub Examples Page at https://github.com/holomodular/ServiceBrick/tree/main/Examples. These projects contain all the source code needed to run the examples.
We have developed two example projects that demonstrate how to run the SERVICE BRICK platform in a single web service project. Each example also includes a Client project that demonstrates how to authenticate and call various methods of the microservices.
- SingleHostSingleDatabase - This example runs the SERVICE BRICK platform and all bricks use the same database for the same provider.
- SingleHostMultipleDatabases - This example runs the SERVICE BRICK platform and all bricks use a different database for the same provider.
Additionally, you can mix and match the storage providers for each of the services, for a full polyglot persistence implementation.
The web application project is built using our WebAppStarterTemplate example project that can be obtained from our GitHub Examples page. It is a barebone, web application that has been configured with Swagger to support API versioning.
When starting the application, if there are no configured users with the ADMIN role, it will open a page to create an ADMIN user.
By default, the email is set to UnitTest@ServiceBrick.com and the password set to UnitTest123!@#
Just click the submit button, as this email and password are configured in the client console app. This will redirect you to the home page. Click the Swagger Link to view the exposed API services and to test calling them.
This must be done prior to running the client console application.
The client project is a console application that starts up dependency injection and makes calls to the web app. As noted above, in the appsetting.json file, it has the web app configuration defined along with the email and password listed above.
Changing Storage Providers
The WebApp project includes several startup files that support all our different storage providers (database engines). Open the Program.cs in the root of the project. Inside of the ConfigureWebHostDefaults() method at the bottom of the file, change the startup file referenced to be any of the included files. Then open the appsettings.json file and change the connection strings for your selected storage provider. By default, it uses all the In-Memory providers, so any data created will be wiped out when stopping the web service.
Each of our example startup files use the same database and same storage provider. However, you can change this to mix and match any of the included different providers per microservice and each use their own database. Try it out!