mirror of
https://github.com/valitydev/three-ds-server-storage.git
synced 2024-11-06 08:25:16 +00:00
BJ-917: Provide logs
This commit is contained in:
parent
468984cfe4
commit
3df63949b5
@ -3,6 +3,7 @@ package com.rbkmoney.threeds.server.storage.client;
|
|||||||
import com.rbkmoney.threeds.server.domain.root.rbkmoney.RBKMoneyPreparationRequest;
|
import com.rbkmoney.threeds.server.domain.root.rbkmoney.RBKMoneyPreparationRequest;
|
||||||
import com.rbkmoney.threeds.server.domain.root.rbkmoney.RBKMoneyPreparationResponse;
|
import com.rbkmoney.threeds.server.domain.root.rbkmoney.RBKMoneyPreparationResponse;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.retry.annotation.Backoff;
|
import org.springframework.retry.annotation.Backoff;
|
||||||
import org.springframework.retry.annotation.EnableRetry;
|
import org.springframework.retry.annotation.EnableRetry;
|
||||||
@ -11,6 +12,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.web.client.RestClientResponseException;
|
import org.springframework.web.client.RestClientResponseException;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
@EnableRetry
|
@EnableRetry
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@ -26,10 +28,15 @@ public class ThreeDsServerClient {
|
|||||||
backoff = @Backoff(delay = 60_000L),
|
backoff = @Backoff(delay = 60_000L),
|
||||||
maxAttempts = Integer.MAX_VALUE)
|
maxAttempts = Integer.MAX_VALUE)
|
||||||
public RBKMoneyPreparationResponse preparationFlow(RBKMoneyPreparationRequest request) {
|
public RBKMoneyPreparationResponse preparationFlow(RBKMoneyPreparationRequest request) {
|
||||||
return restTemplate.postForEntity(
|
log.info("Request: {}", request);
|
||||||
|
|
||||||
|
RBKMoneyPreparationResponse response = restTemplate.postForEntity(
|
||||||
url,
|
url,
|
||||||
request,
|
request,
|
||||||
RBKMoneyPreparationResponse.class)
|
RBKMoneyPreparationResponse.class)
|
||||||
.getBody();
|
.getBody();
|
||||||
|
|
||||||
|
log.info("Response: {}", response);
|
||||||
|
return response;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,10 +21,10 @@ public class RetryListenerConfig {
|
|||||||
public <T, E extends Throwable> void onError(
|
public <T, E extends Throwable> void onError(
|
||||||
RetryContext context, RetryCallback<T, E> callback,
|
RetryContext context, RetryCallback<T, E> callback,
|
||||||
Throwable throwable) {
|
Throwable throwable) {
|
||||||
log.warn("Retrying method={}, count={} because of the exception={}",
|
log.warn("Retrying method={}, count={} because of the exception",
|
||||||
context.getAttribute("context.name"),
|
context.getAttribute("context.name"),
|
||||||
context.getRetryCount(),
|
context.getRetryCount(),
|
||||||
throwable.toString());
|
throwable);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -6,12 +6,14 @@ import com.rbkmoney.threeds.server.storage.mapper.CardRangeMapper;
|
|||||||
import com.rbkmoney.threeds.server.storage.repository.CardRangeRepository;
|
import com.rbkmoney.threeds.server.storage.repository.CardRangeRepository;
|
||||||
import com.rbkmoney.threeds.server.storage.service.PreparationFlowService;
|
import com.rbkmoney.threeds.server.storage.service.PreparationFlowService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static java.util.stream.Collectors.toList;
|
import static java.util.stream.Collectors.toList;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class CardRangesStorageHandler implements CardRangesStorageSrv.Iface {
|
public class CardRangesStorageHandler implements CardRangesStorageSrv.Iface {
|
||||||
@ -22,6 +24,7 @@ public class CardRangesStorageHandler implements CardRangesStorageSrv.Iface {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initRBKMoneyPreparationFlow(InitRBKMoneyPreparationFlowRequest request) {
|
public void initRBKMoneyPreparationFlow(InitRBKMoneyPreparationFlowRequest request) {
|
||||||
|
log.info("Init RBK.money preparation flow for providerId={}", request.getProviderId());
|
||||||
preparationFlowService.init(request.getProviderId());
|
preparationFlowService.init(request.getProviderId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,6 +37,7 @@ public class CardRangesStorageHandler implements CardRangesStorageSrv.Iface {
|
|||||||
.map(mapper::toDomain)
|
.map(mapper::toDomain)
|
||||||
.collect(toList());
|
.collect(toList());
|
||||||
|
|
||||||
|
log.info("Return {} cardRanges for providerId={}", cardRanges.size(), providerId);
|
||||||
return new GetCardRangesResponse()
|
return new GetCardRangesResponse()
|
||||||
.setProviderId(providerId)
|
.setProviderId(providerId)
|
||||||
.setCardRanges(cardRanges);
|
.setCardRanges(cardRanges);
|
||||||
|
@ -7,8 +7,10 @@ import com.rbkmoney.threeds.server.storage.exception.ChallengeFlowTransactionInf
|
|||||||
import com.rbkmoney.threeds.server.storage.mapper.ChallengeFlowTransactionInfoMapper;
|
import com.rbkmoney.threeds.server.storage.mapper.ChallengeFlowTransactionInfoMapper;
|
||||||
import com.rbkmoney.threeds.server.storage.repository.ChallengeFlowTransactionInfoRepository;
|
import com.rbkmoney.threeds.server.storage.repository.ChallengeFlowTransactionInfoRepository;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class ChallengeFlowTransactionInfoStorageHandler implements ChallengeFlowTransactionInfoStorageSrv.Iface {
|
public class ChallengeFlowTransactionInfoStorageHandler implements ChallengeFlowTransactionInfoStorageSrv.Iface {
|
||||||
@ -19,11 +21,14 @@ public class ChallengeFlowTransactionInfoStorageHandler implements ChallengeFlow
|
|||||||
@Override
|
@Override
|
||||||
public void saveChallengeFlowTransactionInfo(ChallengeFlowTransactionInfo transactionInfo) {
|
public void saveChallengeFlowTransactionInfo(ChallengeFlowTransactionInfo transactionInfo) {
|
||||||
ChallengeFlowTransactionInfoEntity entity = mapper.toEntity(transactionInfo);
|
ChallengeFlowTransactionInfoEntity entity = mapper.toEntity(transactionInfo);
|
||||||
|
|
||||||
|
log.debug("Save challengeFlowTransactionInfo with transactionId={}", transactionInfo.getTransactionId());
|
||||||
repository.save(entity);
|
repository.save(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChallengeFlowTransactionInfo getChallengeFlowTransactionInfo(String transactionId) {
|
public ChallengeFlowTransactionInfo getChallengeFlowTransactionInfo(String transactionId) {
|
||||||
|
log.debug("Return challengeFlowTransactionInfo with transactionId={}", transactionId);
|
||||||
return repository.findByTransactionId(transactionId)
|
return repository.findByTransactionId(transactionId)
|
||||||
.map(mapper::toDomain)
|
.map(mapper::toDomain)
|
||||||
.orElseThrow(() -> new ChallengeFlowTransactionInfoNotFoundException("transactionId=" + transactionId));
|
.orElseThrow(() -> new ChallengeFlowTransactionInfoNotFoundException("transactionId=" + transactionId));
|
||||||
|
@ -7,10 +7,12 @@ import com.rbkmoney.threeds.server.storage.mapper.SerialNumMapper;
|
|||||||
import com.rbkmoney.threeds.server.storage.repository.CardRangeRepository;
|
import com.rbkmoney.threeds.server.storage.repository.CardRangeRepository;
|
||||||
import com.rbkmoney.threeds.server.storage.repository.SerialNumRepository;
|
import com.rbkmoney.threeds.server.storage.repository.SerialNumRepository;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.transaction.Transactional;
|
import javax.transaction.Transactional;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class PreparationFlowDataUpdater {
|
public class PreparationFlowDataUpdater {
|
||||||
@ -32,6 +34,14 @@ public class PreparationFlowDataUpdater {
|
|||||||
String providerId = response.getProviderId();
|
String providerId = response.getProviderId();
|
||||||
String serialNum = response.getSerialNum();
|
String serialNum = response.getSerialNum();
|
||||||
|
|
||||||
|
log.info("Update preparation flow data for providerId={}: " +
|
||||||
|
"serialNum={}, cardRanges=[added={}, modified={}, deleted={}]",
|
||||||
|
providerId,
|
||||||
|
serialNum,
|
||||||
|
response.getAddedCardRanges().size(),
|
||||||
|
response.getModifiedCardRanges().size(),
|
||||||
|
response.getDeletedCardRanges().size());
|
||||||
|
|
||||||
cardRangeRepository.saveAll(cardRangeMapper.toEntities(response.getAddedCardRanges(), providerId));
|
cardRangeRepository.saveAll(cardRangeMapper.toEntities(response.getAddedCardRanges(), providerId));
|
||||||
cardRangeRepository.saveAll(cardRangeMapper.toEntities(response.getModifiedCardRanges(), providerId));
|
cardRangeRepository.saveAll(cardRangeMapper.toEntities(response.getModifiedCardRanges(), providerId));
|
||||||
cardRangeRepository.deleteAll(cardRangeMapper.toEntities(response.getDeletedCardRanges(), providerId));
|
cardRangeRepository.deleteAll(cardRangeMapper.toEntities(response.getDeletedCardRanges(), providerId));
|
||||||
|
@ -3,8 +3,9 @@
|
|||||||
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
|
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
|
||||||
<include resource="org/springframework/boot/logging/logback/console-appender.xml"/>
|
<include resource="org/springframework/boot/logging/logback/console-appender.xml"/>
|
||||||
|
|
||||||
<root level="warn">
|
<root level="WARN">
|
||||||
<appender-ref ref="CONSOLE"/>
|
<appender-ref ref="CONSOLE"/>
|
||||||
</root>
|
</root>
|
||||||
<logger name="com.rbkmoney.woody" level="ALL"/>
|
<logger name="com.rbkmoney.woody" level="ALL"/>
|
||||||
|
<logger name="com.rbkmoney.threeds.server.storage" level="DEBUG"/>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
Loading…
Reference in New Issue
Block a user