Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo-catalano committed Jan 19, 2024
1 parent 7b9f0d8 commit 29337c1
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 90 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package it.gov.pagopa.standinmanager.service;

import it.gov.pagopa.standinmanager.config.model.ConfigDataV1;
import java.util.ArrayList;
import lombok.extern.slf4j.Slf4j;
import org.openapitools.client.api.CacheApi;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -24,6 +23,10 @@ public ConfigDataV1 getCache() {

public void loadCache() {
log.info("loadCache from cache api");
configData = cacheApi.cache(false, new ArrayList<>());
try {
configData = cacheApi.cache();
}catch(Exception e){
log.error("Can not get cache",e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,16 @@ public void checkStations() {
ZonedDateTime now = ZonedDateTime.now();
log.info("checkStations [{}]", now);
ConfigDataV1 cache = configService.getCache();
List<CosmosStandInStation> stations = cosmosStationRepository.getStations();
stations.stream().map(s-> Pair.of(s,cache.getStations().get(s.getStation())))
.filter(s->s.getRight()!=null)
.map(s -> checkStation(now, s.getRight(), s.getLeft()))
.collect(Collectors.toList());
if(cache!=null){
List<CosmosStandInStation> stations = cosmosStationRepository.getStations();
stations.stream().map(s-> Pair.of(s,cache.getStations().get(s.getStation())))
.filter(s->s.getRight()!=null)
.map(s -> checkStation(now, s.getRight(), s.getLeft()))
.collect(Collectors.toList());
}else{
log.warn("Can not run,cache is null");
}

}

@Async
Expand Down
17 changes: 9 additions & 8 deletions src/main/resources/application-local.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
server.port=8087
# Info
info.properties.environment=local
# Logging
Expand All @@ -11,18 +12,18 @@ spring.datasource.username=cfg
spring.datasource.password=password

api-config-cache.base-path=https://api.dev.platform.pagopa.it/api-config-cache/o/v1
api-config-cache.api-key=
api-config-cache.api-key=${API_CONFIG_CACHE_API_KEY}

dataexplorer.url=http://localhost:8880
dataexplorer.clientId=
dataexplorer.appKey=
dataexplorer.dbName=NetDefaultDB

cosmos.endpoint=https://pagopa-d-weu-nodo-standin-cosmos-account.documents.azure.com:443/
cosmos.key=
cosmos.endpoint=${COSMOS_STANDIN_URL}
cosmos.key=${COSMOS_STANDIN_KEY}

forwarder.url=https://api.dev.platform.pagopa.it/pagopa-node-forwarder/api/v1/forward
forwarder.key=
forwarder.key=${FORWARDER_KEY}

adder.slot.minutes=5
adder.slot.fault.threshold=1
Expand All @@ -34,14 +35,14 @@ remover.range.fault.limit=6

aws.region=weu
aws.ses.user=[email protected]
aws.mailto=[email protected]
aws.mailto=[email protected]

excludedStations=""

config.refresh.cron= ${CONFIG_REFRESH_CRON}
config.refresh.cron= */10 * * * * *
nodo.monitor.cron= -
nodo.calc.cron= -
station.monitor.cron= */10 * * * * *
station.calc.cron= */10 * * * * *
station.monitor.cron= -
station.calc.cron= -

logging.level.it.gov.pagopa.standinmanager.service=DEBUG
130 changes: 55 additions & 75 deletions src/main/resources/openapi_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"title" : "API-Config Cacher",
"description" : "Generate cache for regarding Nodo dei Pagamenti configuration",
"termsOfService" : "https://www.pagopa.gov.it/",
"version" : "0.8.1"
"version" : "0.8.6"
},
"servers" : [ {
"url" : "http://localhost:8080"
Expand All @@ -22,47 +22,30 @@
}
} ],
"paths" : {
"/stakeholders/node/cache/schemas/v1" : {
"/stakeholders/standin/cache/schemas/v1" : {
"get" : {
"tags" : [ "Cache" ],
"summary" : "Get selected key of cache v1 config",
"operationId" : "cache",
"parameters" : [ {
"name" : "refresh",
"in" : "query",
"description" : "to force the refresh of the cache",
"required" : false,
"schema" : {
"type" : "boolean"
}
}, {
"name" : "keys",
"in" : "query",
"required" : false,
"schema" : {
"type" : "array",
"items" : {
"type" : "string",
"enum" : [ "creditorInstitutions", "creditorInstitutionBrokers", "stations", "creditorInstitutionStations", "encodings", "creditorInstitutionEncodings", "ibans", "creditorInstitutionInformations", "psps", "pspBrokers", "paymentTypes", "pspChannelPaymentTypes", "plugins", "pspInformationTemplates", "pspInformations", "channels", "cdsServices", "cdsSubjects", "cdsSubjectServices", "cdsCategories", "configurations", "ftpServers", "languages", "gdeConfigurations", "metadataDict" ]
}
}
} ],
"responses" : {
"403" : {
"description" : "Forbidden"
},
"200" : {
"description" : "OK",
"400" : {
"description" : "Bad Request",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/ConfigDataV1"
"$ref" : "#/components/schemas/ProblemJson"
}
}
}
},
"400" : {
"description" : "Bad Request",
"401" : {
"description" : "Unauthorized"
},
"403" : {
"description" : "Forbidden"
},
"500" : {
"description" : "Service unavailable",
"content" : {
"application/json" : {
"schema" : {
Expand All @@ -74,15 +57,12 @@
"429" : {
"description" : "Too many requests"
},
"401" : {
"description" : "Unauthorized"
},
"500" : {
"description" : "Service unavailable",
"200" : {
"description" : "OK",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/ProblemJson"
"$ref" : "#/components/schemas/ConfigDataV1"
}
}
}
Expand All @@ -93,18 +73,12 @@
} ]
}
},
"/stakeholders/node/cache/schemas/v1/id" : {
"/stakeholders/standin/cache/schemas/v1/id" : {
"get" : {
"tags" : [ "Cache" ],
"summary" : "Get last v1 cache version",
"operationId" : "idV1",
"responses" : {
"404" : {
"description" : "Not Found"
},
"403" : {
"description" : "Forbidden"
},
"400" : {
"description" : "Bad Request",
"content" : {
Expand All @@ -115,28 +89,34 @@
}
}
},
"429" : {
"description" : "Too many requests"
"401" : {
"description" : "Unauthorized"
},
"200" : {
"description" : "OK",
"403" : {
"description" : "Forbidden"
},
"404" : {
"description" : "Not Found"
},
"500" : {
"description" : "Service unavailable",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/CacheVersion"
"$ref" : "#/components/schemas/ProblemJson"
}
}
}
},
"401" : {
"description" : "Unauthorized"
"429" : {
"description" : "Too many requests"
},
"500" : {
"description" : "Service unavailable",
"200" : {
"description" : "OK",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/ProblemJson"
"$ref" : "#/components/schemas/CacheVersion"
}
}
}
Expand All @@ -150,6 +130,28 @@
},
"components" : {
"schemas" : {
"ProblemJson" : {
"type" : "object",
"properties" : {
"title" : {
"type" : "string",
"description" : "A short, summary of the problem type. Written in english and readable for engineers (usually not suited for non technical stakeholders and not localized); example: Service Unavailable"
},
"status" : {
"maximum" : 600,
"minimum" : 100,
"type" : "integer",
"description" : "The HTTP status code generated by the origin server for this occurrence of the problem.",
"format" : "int32",
"example" : 200
},
"detail" : {
"type" : "string",
"description" : "A human readable explanation specific to this occurrence of the problem.",
"example" : "There was an error processing the request"
}
}
},
"BrokerCreditorInstitution" : {
"required" : [ "broker_code", "enabled", "extended_fault_bean" ],
"type" : "object",
Expand Down Expand Up @@ -995,28 +997,6 @@
}
}
},
"ProblemJson" : {
"type" : "object",
"properties" : {
"title" : {
"type" : "string",
"description" : "A short, summary of the problem type. Written in english and readable for engineers (usually not suited for non technical stakeholders and not localized); example: Service Unavailable"
},
"status" : {
"maximum" : 600,
"minimum" : 100,
"type" : "integer",
"description" : "The HTTP status code generated by the origin server for this occurrence of the problem.",
"format" : "int32",
"example" : 200
},
"detail" : {
"type" : "string",
"description" : "A human readable explanation specific to this occurrence of the problem.",
"example" : "There was an error processing the request"
}
}
},
"CacheVersion" : {
"required" : [ "version" ],
"type" : "object",
Expand Down

0 comments on commit 29337c1

Please sign in to comment.