Changes for multi schematic Services
Follow the generic updates before starting with the following changes
General update for services to be Central-Instance compatible
Application.properties variables to be added
state.level.tenantid.length=2
State-level tenant value will be picked from the full tenant-id separated by the '.' dot. once the tenant-id is separated by dot the resulting array of size given above will be considered state level.is.environment.central.instance=true
Declares whether the environment in which the service is deployed belong to a central-instance kind of setup.
The both above said variable has to be overridden in the values YAML file of the respective service to pick up the values from the environment.
{{- if index .Values "global" "is-environment-central-instance" }} - name: IS_ENVIRONMENT_CENTRAL_INSTANCE valueFrom: configMapKeyRef: name: egov-config key: is-environment-central-instance {{- end }} {{- if index .Values "global" "is-environment-central-instance" }} - name: STATE_LEVEL_TENANTID_LENGTH valueFrom: configMapKeyRef: name: egov-config key: state-level-tenantid-length {{- end }}
The host of the state-specific services referred by this service should be changed to the internal gateway host for tenant-based(namespace) redirection.
- name: EGOV_TL_CALCULATOR_HOST valueFrom: configMapKeyRef: name: egov-service-host key: internal-gateway
Sample values YAML file to refer to the above-said changes
If this service allows the search of data without tenant-id then the following validation should be added to all the search APIs belonging to the service. searches without state-level tenant-id (as described by this variable - state.level.tenantid.length) will render the application useless, so the following is mandatory
if(configs.getIsEnvironmentCentralInstance() && criteria.getTenantId() == null) throw new CustomException("EG_PT_INVALID_SEARCH"," TenantId is mandatory for search "); else if(configs.getIsEnvironmentCentralInstance() && criteria.getTenantId().split("\\.").length < configs.getStateLevelTenantIdLength()) throw new CustomException("EG_PT_INVALID_SEARCH"," TenantId should be mandatorily " + configs.getStateLevelTenantIdLength() + " levels for search");
Update the Kafka producer in the service with the following code to enable the service to post to a tenant(namespace) specific topic based on the tenant-id.
Replace all the table names in the queries present with the {schema} placeholder
Add the following Schema replacer utility method and use the same to replace all queries with the respective schema.
Change the persister config to alter the Kafka topic names for the configs belonging to your respective multi-schema service. The kafka topic name should be appended with the schema name of the respective state schema.