Registries
Introduction
SOAJS Environments are each equipped with a registry that contains information such as security encryption phrases, logging configuration, domain information, infrastructure deployment driver and how to connect to it ... etc
In Addition SOAJS also provides the ability to extend the default registry and allow you to have add custom entries that you need in your code.
The registry is pulled from the database and cached in memory for every microservice that launches in the environment. The registry is then reloaded when the caching limit runs out.
Changes you make take effect once the registry is auto reloaded or if you force a reload registry maintenance operation.
You can learn more about SOAJS registry and what it offers on this page.
Objective
Managing Registries
Head to the Deploy pillar, you will notice that in the left sidebar a drop down appears in RED. This drop down contains the codes of all the environments you have created so far.
Click on Registries Module, the registry of the environment you have selected in the drop down show up.
From that interface you can learn about all the configuration that this registry currently offers to all the microservices and daemons that are running in this environment.
Every time you create a new environment, SOAJS creates a registry for it and stores it in the core database by default.
Edit Registry
You can edit the registry of an environment and update all the settings it contains except the environment code.
Some of the settings get updated once you trigger the reload registry maintenance operation of the services running in this environment whereas other settings require you restart the services so that the effect takes place.
Either way, the UI interface displays and elaborates which settings requires a service restart and which don't.
Key Security Update
While editing your registry, you notice a section at the bottom named tenant key security with a highlighted Note box above its form.
This section is highly sensitive as it allows you to change the security encryption phrase that is used to encrypt all the tenants that have keys associated with this environment.
Changing the security phrase in any environment will trigger a background process that loops around all the tenants you have and:
- Flag all old keys for this environment as deprecated
- Generate new keys for this environment and update all the tenants affected.
If the environment happens to be Dashboard, SOAJS will prompt you with a new external key value that YOU MUST CHANGE in the settings.js of the UI that loads via Nginx, otherwise all the calls that the UI makes after this event will fail since the key it contains is now deprecated.
The same behavior happens in every environment, once you change the security phrase, make sure to update the interfaces & devices that integrates with your APIs by changing the key values to the newly generated ones otherwise all calls to your APIs will fail.
Note:
Concerning the Dashboard UI Interface, the settings.js that the default SOAJS dashboard uses resides in: https://github.com/soajs/soajs.dashboard.ui/settings.js and the default external key is on line 3.
The wizard will inform you about the update after it happens along with the instructions you should do to move forward.
Custom Registry
Custom registries are accessible after you create an environment and allow you to extend the default registry add your own configuration entries.
Custom registries:
- Support all data types
- Can be locked, thus only get modified by the creator or the root owner
- Shared among environments
- Plugged and Unplugged from the registry ( only plugged entries in the registry can be access via the code )
Accessing the Registry in the code
The registry provide private configuration related to the environment that services and daemons are operating in. These inputs are acquired from the registry via SOAJS object at runtime: req.soajs.registry and contain registry and custom registry settings.
You can read in depth about all the properties and information that the registry supplies inside the SOAJS Space → Registry section.