Skip to content

Commit

Permalink
migrate to cosmos mongo db reactive
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaconsalvi committed Nov 28, 2024
1 parent 29466ce commit 6598639
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 141 deletions.
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,14 @@ ext {
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-webflux'
implementation 'org.springframework.boot:spring-boot-starter-data-mongodb-reactive'

// spring security + oauth2 resource server
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-resource-server'
implementation 'org.springframework.security:spring-security-oauth2-jose'
implementation("org.springframework.boot:spring-boot-starter-actuator")

// implementation 'com.azure.spring:spring-cloud-azure-starter-actuator'
implementation 'com.azure.spring:spring-cloud-azure-starter-data-cosmos'
implementation("io.swagger.core.v3:swagger-annotations:2.2.8")
implementation("org.openapitools:jackson-databind-nullable:0.2.6")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310")
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package it.gov.pagopa.rtp.activator.repository;

import com.azure.spring.data.cosmos.repository.ReactiveCosmosRepository;


import org.springframework.data.mongodb.repository.ReactiveMongoRepository;
import org.springframework.stereotype.Repository;

import reactor.core.publisher.Mono;

public interface ActivationDB extends ReactiveCosmosRepository<ActivationEntity, String> {
@Repository
public interface ActivationDB extends ReactiveMongoRepository<ActivationEntity, String> {
Mono<ActivationEntity> findByFiscalCode(String fiscalCode);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import java.time.Instant;

import com.azure.spring.data.cosmos.core.mapping.Container;
import com.azure.spring.data.cosmos.core.mapping.PartitionKey;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

import lombok.AllArgsConstructor;
import lombok.Builder;
Expand All @@ -14,12 +14,12 @@
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Container(containerName = "activations", autoCreateContainer = false)
@Document("activations")
public class ActivationEntity {
@Id
private String id;
private String rtpSpId;
private Instant effectiveActivationDate;

@PartitionKey
private String fiscalCode;
}
5 changes: 2 additions & 3 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ management.endpoint.health.probes.enabled=true

#repository

azure.cosmos.uri=${COSMOS_ACCOUNT_RTP_ENDPOINT:}
azure.cosmos.key=${AZURE_COSMOS_KEY:}
azure.cosmos.database=${DB_NAME:rtp}
spring.data.mongodb.uri=${COSMOS_ACCOUNT_RTP_CONNECTION_STRING:}
spring.data.mongodb.database=${DB_NAME:rtp}
activation.base-url=${BASE_URL:http://localhost}
2 changes: 1 addition & 1 deletion src/main/terraform/env/cstar-d-weu-rtp/terraform.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ rtp_activator_base_url = "https://mil-d-apim.azure-api.


rtp_environment_secrets = {
COSMOS_ACCOUNT_RTP_ENDPOINT : "cosmosdb-account-rtp-endpoint"
COSMOS_ACCOUNT_RTP_CONNECTION_STRING : "cosmosdb-account-rtp-connection-string"
AZURE_COSMOS_KEY : "azure-cosmos-key"
APPLICATIONINSIGHTS_CONNECTION_STRING : "appinsights-connection-string"
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/terraform/env/cstar-p-weu-rtp/terraform.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ rtp_activator_min_replicas = 1
rtp_activator_base_url = "https://mil-d-apim.azure-api.net/rtp_activator"

rtp_environment_secrets = {
COSMOS_ACCOUNT_RTP_ENDPOINT : "cosmosdb-account-rtp-endpoint"
COSMOS_ACCOUNT_RTP_CONNECTION_STRING : "cosmosdb-account-rtp-connection-string"
APPLICATIONINSIGHTS_CONNECTION_STRING : "appinsights-connection-string"
AZURE_COSMOS_KEY : "azure-cosmos-key"
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/terraform/env/cstar-u-weu-rtp/terraform.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ rtp_activator_base_url = "https://mil-d-apim.azure-api.


rtp_environment_secrets = {
COSMOS_ACCOUNT_RTP_ENDPOINT : "cosmosdb-account-rtp-endpoint"
COSMOS_ACCOUNT_RTP_CONNECTION_STRING : "cosmosdb-account-rtp-connection-string"
APPLICATIONINSIGHTS_CONNECTION_STRING : "appinsights-connection-string"
AZURE_COSMOS_KEY : "azure-cosmos-key"
}
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit 6598639

Please sign in to comment.