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

  1. 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.

  2. is.environment.central.instance=true

    Declares whether the environment in which the service is deployed belong to a central-instance kind of setup.

  3. 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 }}

     

  4. 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

    https://github.com/egovernments/DIGIT-DevOps/blob/central-instance/deploy-as-code/helm/charts/municipal-services/property-services/values.yaml

  5. 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");

     

  6. 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.

  7. Replace all the table names in the queries present with the {schema} placeholder

     

  8. Add the following Schema replacer utility method and use the same to replace all queries with the respective schema.

     

  9. 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.