diff --git a/.env.example b/.env.example index d940664b..2646df7b 100644 --- a/.env.example +++ b/.env.example @@ -23,6 +23,7 @@ MONGO_WAITING_QUEUE_MS=2000 MONGO_HEARTBEAT_FREQUENCY_MS=5000 SEARCH_DEAD_LETTER_QUEUE_MAPPING={ ALL: '*', ECOMMERCE: 'pagopa-ecommerce-transactions-dead-letter-queue', NOTIFICATIONS_SERVICE: 'pagopa-ecommerce-notifications-service-errors-queue' } +SEARCH_PM_IN_ECOMMERCE_HISTORY_ENABLED=false PERSONAL_DATA_VAULT_API_KEY=personal-data-vault-api-key PERSONAL_DATA_VAULT_API_BASE_PATH="http://pagopa-pdv-mock:8080" \ No newline at end of file diff --git a/README.md b/README.md index 11c6bfcf..0898d861 100644 --- a/README.md +++ b/README.md @@ -63,34 +63,35 @@ to get a good default configuration. If you want to customize the application environment, reference this table: -| Variable name | Description | type | default | -|-----------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------|---------| -| DEFAULT_LOGGING_LEVEL | Default root application logging level | string | INFO | -| APP_LOGGING_LEVEL | Application logging level | string | INFO | -| WEB_LOGGING_LEVEL | Web logging level | string | INFO | -| MONGO_HOST | MongoDB ecommerce hostname instance | hostname (string) | | -| MONGO_PORT | Port where MongoDB is bound to in MongoDB host | number | | -| MONGO_USERNAME | MongoDB username used to connect to the database | string | | -| MONGO_PASSWORD | MongoDB password used to connect to the database | string | | -| MONGO_SSL_ENABLED | Whether SSL is enabled while connecting to MongoDB | string | | -| MONGO_PORT | Port used for connecting to MongoDB instance | string | | -| MONGO_MIN_POOL_SIZE | Min amount of connections to be retained into connection pool. See docs * | string | | -| MONGO_MAX_POOL_SIZE | Max amount of connections to be retained into connection pool.See docs * | string | | -| MONGO_MAX_IDLE_TIMEOUT_MS | Max timeout after which an idle connection is killed in milliseconds. See docs * | string | | -| MONGO_CONNECTION_TIMEOUT_MS | Max time to wait for a connection to be opened. See docs * | string | | -| MONGO_SOCKET_TIMEOUT_MS | Max time to wait for a command send or receive before timing out. See docs * | string | | -| MONGO_SERVER_SELECTION_TIMEOUT_MS | Max time to wait for a server to be selected while performing a communication with Mongo in milliseconds. See docs * | string | | -| MONGO_WAITING_QUEUE_MS | Max time a thread has to wait for a connection to be available in milliseconds. See docs * | string | | -| MONGO_HEARTBEAT_FREQUENCY_MS | Hearth beat frequency in milliseconds. This is an hello command that is sent periodically on each active connection to perform an health check. See docs * | string | | -| MONGO_REPLICA_SET_OPTION | The replica set connection string option valued with the name of the replica set. See docs * | string | | -| PERSONAL_DATA_VAULT_API_KEY | API Key for Personal Data Vault (PDV is used to safely encrypt PIIs, e.g. the user's email address) | string | | -| PERSONAL_DATA_VAULT_API_BASE_PATH | API base path for Personal Data Vault | string | | -| PM_ORACLE_HOST | PM Oracle DB hostname instance | hostname (string) | | -| PM_ORACLE_PORT | PM Oracle DB port | int | | -| PM_ORACLE_DATABASE_NAME | PM Oracle DB database name | string | | -| PM_ORACLE_USERNAME | PM Oracle DB username | string | | -| PM_ORACLE_PASSWORD | PM Oracle DB password | string | | -| SEARCH_DEAD_LETTER_QUEUE_MAPPING | Dead letter search criteria to queue name mapping | map(string,string) | | +| Variable name | Description | type | default | +|----------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------|---------| +| DEFAULT_LOGGING_LEVEL | Default root application logging level | string | INFO | +| APP_LOGGING_LEVEL | Application logging level | string | INFO | +| WEB_LOGGING_LEVEL | Web logging level | string | INFO | +| MONGO_HOST | MongoDB ecommerce hostname instance | hostname (string) | | +| MONGO_PORT | Port where MongoDB is bound to in MongoDB host | number | | +| MONGO_USERNAME | MongoDB username used to connect to the database | string | | +| MONGO_PASSWORD | MongoDB password used to connect to the database | string | | +| MONGO_SSL_ENABLED | Whether SSL is enabled while connecting to MongoDB | string | | +| MONGO_PORT | Port used for connecting to MongoDB instance | string | | +| MONGO_MIN_POOL_SIZE | Min amount of connections to be retained into connection pool. See docs * | string | | +| MONGO_MAX_POOL_SIZE | Max amount of connections to be retained into connection pool.See docs * | string | | +| MONGO_MAX_IDLE_TIMEOUT_MS | Max timeout after which an idle connection is killed in milliseconds. See docs * | string | | +| MONGO_CONNECTION_TIMEOUT_MS | Max time to wait for a connection to be opened. See docs * | string | | +| MONGO_SOCKET_TIMEOUT_MS | Max time to wait for a command send or receive before timing out. See docs * | string | | +| MONGO_SERVER_SELECTION_TIMEOUT_MS | Max time to wait for a server to be selected while performing a communication with Mongo in milliseconds. See docs * | string | | +| MONGO_WAITING_QUEUE_MS | Max time a thread has to wait for a connection to be available in milliseconds. See docs * | string | | +| MONGO_HEARTBEAT_FREQUENCY_MS | Hearth beat frequency in milliseconds. This is an hello command that is sent periodically on each active connection to perform an health check. See docs * | string | | +| MONGO_REPLICA_SET_OPTION | The replica set connection string option valued with the name of the replica set. See docs * | string | | +| PERSONAL_DATA_VAULT_API_KEY | API Key for Personal Data Vault (PDV is used to safely encrypt PIIs, e.g. the user's email address) | string | | +| PERSONAL_DATA_VAULT_API_BASE_PATH | API base path for Personal Data Vault | string | | +| PM_ORACLE_HOST | PM Oracle DB hostname instance | hostname (string) | | +| PM_ORACLE_PORT | PM Oracle DB port | int | | +| PM_ORACLE_DATABASE_NAME | PM Oracle DB database name | string | | +| PM_ORACLE_USERNAME | PM Oracle DB username | string | | +| PM_ORACLE_PASSWORD | PM Oracle DB password | string | | +| SEARCH_DEAD_LETTER_QUEUE_MAPPING | Dead letter search criteria to queue name mapping | map(string,string) | | +| SEARCH_PM_IN_ECOMMERCE_HISTORY_ENABLED | Whether the search by fiscal code is made through the history (false) or ecommerce (true) database | string | false | (*): for Mongo connection string options see [docs](https://www.mongodb.com/docs/drivers/java/sync/v4.3/fundamentals/connection/connection-options/#connection-options) diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 50793aa3..808e5398 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -89,6 +89,7 @@ microservice-chart: MONGO_HEARTBEAT_FREQUENCY_MS: "5000" SEARCH_DEAD_LETTER_QUEUE_MAPPING: > {ALL: '*', ECOMMERCE: 'pagopa-d-weu-ecommerce-transactions-dead-letter-queue', NOTIFICATIONS_SERVICE: 'pagopa-d-weu-ecommerce-notifications-service-errors-queue'} + SEARCH_PM_IN_ECOMMERCE_HISTORY_ENABLED: "false" envSecret: OTEL_EXPORTER_OTLP_HEADERS: elastic-otel-token-header diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index cd13a0c0..f76119a9 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -45,6 +45,7 @@ microservice-chart: MONGO_REPLICA_SET_OPTION: "&replicaSet=globaldb" SEARCH_DEAD_LETTER_QUEUE_MAPPING: > {ALL: '*', ECOMMERCE: 'pagopa-p-weu-ecommerce-transactions-dead-letter-queue', NOTIFICATIONS_SERVICE: 'pagopa-p-weu-ecommerce-notifications-service-errors-queue'} + SEARCH_PM_IN_ECOMMERCE_HISTORY_ENABLED: "false" envSecret: OTEL_EXPORTER_OTLP_HEADERS: elastic-otel-token-header @@ -140,6 +141,7 @@ microservice-chart: MONGO_REPLICA_SET_OPTION: "&replicaSet=globaldb" SEARCH_DEAD_LETTER_QUEUE_MAPPING: > {ALL: '*', ECOMMERCE: 'pagopa-p-weu-ecommerce-transactions-dead-letter-queue', NOTIFICATIONS_SERVICE: 'pagopa-p-weu-ecommerce-notifications-service-errors-queue'} + SEARCH_PM_IN_ECOMMERCE_HISTORY_ENABLED: "false" envSecret: OTEL_EXPORTER_OTLP_HEADERS: elastic-otel-token-header diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 4465e24b..341029ef 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -44,6 +44,7 @@ microservice-chart: MONGO_HEARTBEAT_FREQUENCY_MS: "5000" SEARCH_DEAD_LETTER_QUEUE_MAPPING: > {ALL: '*', ECOMMERCE: 'pagopa-u-weu-ecommerce-transactions-dead-letter-queue', NOTIFICATIONS_SERVICE: 'pagopa-u-weu-ecommerce-notifications-service-errors-queue'} + SEARCH_PM_IN_ECOMMERCE_HISTORY_ENABLED: "false" envSecret: OTEL_EXPORTER_OTLP_HEADERS: elastic-otel-token-header @@ -138,6 +139,7 @@ microservice-chart: MONGO_HEARTBEAT_FREQUENCY_MS: "5000" SEARCH_DEAD_LETTER_QUEUE_MAPPING: > {ALL: '*', ECOMMERCE: 'pagopa-u-weu-ecommerce-transactions-dead-letter-queue', NOTIFICATIONS_SERVICE: 'pagopa-u-weu-ecommerce-notifications-service-errors-queue'} + SEARCH_PM_IN_ECOMMERCE_HISTORY_ENABLED: "false" envSecret: OTEL_EXPORTER_OTLP_HEADERS: elastic-otel-token-header diff --git a/src/main/kotlin/it/pagopa/ecommerce/helpdesk/controllers/v1/PmController.kt b/src/main/kotlin/it/pagopa/ecommerce/helpdesk/controllers/v1/PmController.kt index 6e75bed1..65846426 100644 --- a/src/main/kotlin/it/pagopa/ecommerce/helpdesk/controllers/v1/PmController.kt +++ b/src/main/kotlin/it/pagopa/ecommerce/helpdesk/controllers/v1/PmController.kt @@ -10,13 +10,18 @@ import jakarta.validation.constraints.Max import jakarta.validation.constraints.Min import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Autowired +import org.springframework.beans.factory.annotation.Value import org.springframework.http.ResponseEntity import org.springframework.web.bind.annotation.RestController import org.springframework.web.server.ServerWebExchange import reactor.core.publisher.Mono @RestController("PmV1Controller") -class PmController(@Autowired val pmService: PmService) : PmApi { +class PmController( + @Autowired val pmService: PmService, + @Value("\${search.pm.in.ecommerce.history.enabled:false}") + private val searchPmInEcommerceHistory: Boolean +) : PmApi { private val logger = LoggerFactory.getLogger(this.javaClass) override fun pmSearchTransaction( @@ -25,7 +30,9 @@ class PmController(@Autowired val pmService: PmService) : PmApi { pmSearchTransactionRequestDto: Mono, exchange: ServerWebExchange ): Mono> { - logger.info("[HelpDesk controller] pmSearchTransaction") + logger.info( + "[HelpDesk controller] SearchTransaction using ${if (searchPmInEcommerceHistory) "v2 (ecommerce db)" else "v1 (history db)"} search" + ) return pmSearchTransactionRequestDto .flatMap { pmService.searchTransaction( diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 3372a2c6..14a119a8 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -29,3 +29,5 @@ deadLetter.queueMapping=\${SEARCH_DEAD_LETTER_QUEUE_MAPPING} #PDV configuration confidentialDataManager.personalDataVault.apiKey=\${PERSONAL_DATA_VAULT_API_KEY} confidentialDataManager.personalDataVault.apiBasePath=\${PERSONAL_DATA_VAULT_API_BASE_PATH} +# feature flags +search.pm.in.ecommerce.history.enabled=\${SEARCH_PM_IN_ECOMMERCE_HISTORY_ENABLED} \ No newline at end of file diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties index eec0755e..df748cf6 100644 --- a/src/test/resources/application.properties +++ b/src/test/resources/application.properties @@ -28,3 +28,5 @@ deadLetter.queueMapping={ ALL: '*', ECOMMERCE: 'pagopa-ecommerce-transactions-de #PDV configuration confidentialDataManager.personalDataVault.apiKey=personal-data-vault-api-key confidentialDataManager.personalDataVault.apiBasePath=http://personal-data-vault-test-host/v1/api +# feature flags +search.pm.in.ecommerce.history.enabled=false