[NO-ISSUE] Implement v2
This commit is contained in:
26
reader/build.gradle
Normal file
26
reader/build.gradle
Normal file
@@ -0,0 +1,26 @@
|
||||
dependencies {
|
||||
developmentOnly 'org.springframework.boot:spring-boot-devtools'
|
||||
runtimeOnly 'com.h2database:h2'
|
||||
runtimeOnly 'mysql:mysql-connector-java'
|
||||
compileOnly 'org.projectlombok:lombok'
|
||||
|
||||
implementation project(':support')
|
||||
// https://projectreactor.io/docs/core/release/reference/#debug-activate
|
||||
implementation 'org.springframework.boot:spring-boot-starter-webflux'
|
||||
implementation 'org.springframework.boot:spring-boot-configuration-processor'
|
||||
implementation 'org.springframework.cloud:spring-cloud-starter-config'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-actuator'
|
||||
implementation 'org.telegram:telegrambots:5.3.0'
|
||||
|
||||
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
|
||||
annotationProcessor 'org.projectlombok:lombok'
|
||||
|
||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||
}
|
||||
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
testLogging {
|
||||
events "passed", "skipped", "failed"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.myoa.engineering.crawl.ppomppu.reader;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import com.myoa.engineering.crawl.shopping.support.webclient.PpomppuNotifierWebClientConfiguration;
|
||||
|
||||
/**
|
||||
* ReceiverApplication
|
||||
* @author Shin Woo-jin (woo-jin.shin@linecorp.com)
|
||||
* @since 2021-08-20
|
||||
*
|
||||
*/
|
||||
@Import({ PpomppuNotifierWebClientConfiguration.class})
|
||||
@SpringBootApplication
|
||||
// @EnableConfigurationProperties({ TelegramBotProperties.class })
|
||||
public class ReaderApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ReaderApplication.class, args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.myoa.engineering.crawl.ppomppu.reader.configuration;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.telegram.telegrambots.meta.TelegramBotsApi;
|
||||
import org.telegram.telegrambots.meta.exceptions.TelegramApiException;
|
||||
import org.telegram.telegrambots.updatesreceivers.DefaultBotSession;
|
||||
|
||||
import com.myoa.engineering.crawl.ppomppu.reader.configuration.properties.TelegramBotProperties;
|
||||
import com.myoa.engineering.crawl.ppomppu.reader.configuration.properties.TelegramBotProperties.TelegramBotPropertiesUnit;
|
||||
import com.myoa.engineering.crawl.ppomppu.reader.dispatch.MessageDispatcher;
|
||||
import com.myoa.engineering.crawl.ppomppu.reader.handler.message.MessageHandler;
|
||||
|
||||
/**
|
||||
* TelegramBotConfiguration
|
||||
* @author Shin Woo-jin (woo-jin.shin@linecorp.com)
|
||||
* @since 2021-08-21
|
||||
*
|
||||
*/
|
||||
@Configuration
|
||||
public class TelegramBotConfiguration {
|
||||
|
||||
private static final String BOT_PROPERTIES_UNIT_NAME = "ppomppu_notify_bot";
|
||||
@Bean
|
||||
public TelegramBotsApi telegramBotsApi(MessageDispatcher messageDispatcher) throws TelegramApiException {
|
||||
TelegramBotsApi api = new TelegramBotsApi(DefaultBotSession.class);
|
||||
api.registerBot(messageDispatcher);
|
||||
return api;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MessageDispatcher messageDispatcher(List<MessageHandler> messageHandlers,
|
||||
TelegramBotProperties telegramBotProperties) {
|
||||
TelegramBotPropertiesUnit propertiesUnit = telegramBotProperties.find(BOT_PROPERTIES_UNIT_NAME);
|
||||
return new MessageDispatcher(messageHandlers, propertiesUnit.getName(), propertiesUnit.getToken());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.myoa.engineering.crawl.ppomppu.reader.configuration.properties;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* TelegramBotProperties
|
||||
* @author Shin Woo-jin (woo-jin.shin@linecorp.com)
|
||||
* @since 2021-09-05
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
@Setter
|
||||
@Getter
|
||||
@ConfigurationProperties(prefix = "infra.telegram.bot")
|
||||
public class TelegramBotProperties {
|
||||
|
||||
private List<TelegramBotPropertiesUnit> units = new ArrayList<>();
|
||||
|
||||
@Data
|
||||
public static class TelegramBotPropertiesUnit {
|
||||
private String unitName;
|
||||
private String name;
|
||||
private String token;
|
||||
}
|
||||
|
||||
public TelegramBotPropertiesUnit find(String unitName) {
|
||||
return units.stream()
|
||||
.filter(e -> e.getUnitName().equals(unitName))
|
||||
.findFirst()
|
||||
.orElseThrow(
|
||||
() -> new IllegalArgumentException(this.getClass().getName() + ": unitName Not found. " + unitName));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.myoa.engineering.crawl.ppomppu.reader.controller.v1;
|
||||
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.myoa.engineering.crawl.ppomppu.reader.service.ProcessorAPIService;
|
||||
import com.myoa.engineering.crawl.shopping.support.dto.constant.PpomppuBoardName;
|
||||
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
/**
|
||||
* EventAPIController
|
||||
* @author Shin Woo-jin (woo-jin.shin@linecorp.com)
|
||||
* @since 2021-09-05
|
||||
*
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/")
|
||||
public class EventAPIController {
|
||||
|
||||
private final ProcessorAPIService processorAPIService;
|
||||
|
||||
public EventAPIController(ProcessorAPIService processorAPIService) {
|
||||
this.processorAPIService = processorAPIService;
|
||||
}
|
||||
|
||||
@PostMapping("/exploit/parsePpomppuRSS/{boardName}")
|
||||
public Mono<String> parsePpomppuRSS(@PathVariable("boardName") PpomppuBoardName boardName) {
|
||||
return processorAPIService.emitParseEvent(boardName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.myoa.engineering.crawl.ppomppu.reader.dispatch;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.telegram.telegrambots.bots.TelegramLongPollingBot;
|
||||
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||
import org.telegram.telegrambots.meta.api.objects.Update;
|
||||
|
||||
import com.myoa.engineering.crawl.ppomppu.reader.handler.message.MessageHandler;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class MessageDispatcher extends TelegramLongPollingBot {
|
||||
|
||||
private final List<MessageHandler> messageHandlers;
|
||||
private final String botName;
|
||||
private final String botToken;
|
||||
|
||||
public MessageDispatcher(List<MessageHandler> messageHandlers, String botName, String botToken) {
|
||||
this.messageHandlers = messageHandlers;
|
||||
this.botName = botName;
|
||||
this.botToken = botToken;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBotToken() {
|
||||
return botToken;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateReceived(Update update) {
|
||||
|
||||
Message message = update.getMessage();
|
||||
MessageHandler handler = getMessageHandler(message);
|
||||
handler.handle(message);
|
||||
}
|
||||
|
||||
private MessageHandler getMessageHandler(Message message) {
|
||||
return messageHandlers.stream()
|
||||
.filter(e -> e.isApplicable(message))
|
||||
.findFirst()
|
||||
.orElseThrow(() -> new IllegalArgumentException("Can not found applicable handler"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBotUsername() {
|
||||
return botName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.myoa.engineering.crawl.ppomppu.reader.handler.message;
|
||||
|
||||
import com.myoa.engineering.crawl.shopping.support.util.ObjectUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class HelloWorldMessageHandler implements MessageHandler {
|
||||
|
||||
@Override
|
||||
public boolean isApplicable(Message message) {
|
||||
return ObjectUtil.isEmpty(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(Message message) {
|
||||
// skip empty event message.
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.myoa.engineering.crawl.ppomppu.reader.handler.message;
|
||||
|
||||
/**
|
||||
* ImageHandler
|
||||
* @author Shin Woo-jin (woo-jin.shin@linecorp.com)
|
||||
* @since 2021-08-21
|
||||
*
|
||||
*/
|
||||
public interface ImageMessageHandler extends MessageHandler {
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.myoa.engineering.crawl.ppomppu.reader.handler.message;
|
||||
|
||||
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||
|
||||
/**
|
||||
* MessageHandler
|
||||
* @author Shin Woo-jin (woo-jin.shin@linecorp.com)
|
||||
* @since 2021-08-21
|
||||
*
|
||||
*/
|
||||
public interface MessageHandler {
|
||||
|
||||
boolean isApplicable(Message message);
|
||||
|
||||
void handle(Message message);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.myoa.engineering.crawl.ppomppu.reader.handler.message;
|
||||
|
||||
import com.myoa.engineering.crawl.shopping.support.util.ObjectUtil;
|
||||
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||
|
||||
/**
|
||||
* TextMessageHandler
|
||||
*
|
||||
* @author Shin Woo-jin (woo-jin.shin@linecorp.com)
|
||||
* @since 2021-08-21
|
||||
*/
|
||||
public interface TextMessageHandler extends MessageHandler {
|
||||
|
||||
@Override
|
||||
default boolean isApplicable(Message message) {
|
||||
return ObjectUtil.isNotEmpty(message) && message.isUserMessage() && message.hasText();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.myoa.engineering.crawl.ppomppu.reader.handler.message.text;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||
|
||||
import com.myoa.engineering.crawl.ppomppu.reader.handler.message.TextMessageHandler;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* CommandHandler
|
||||
* @author Shin Woo-jin (woo-jin.shin@linecorp.com)
|
||||
* @since 2021-08-21
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class CommandHandler implements TextMessageHandler {
|
||||
|
||||
private final List<TextCommandProcessor> processors;
|
||||
|
||||
public CommandHandler(List<TextCommandProcessor> processors) {
|
||||
this.processors = processors;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isApplicable(Message message) {
|
||||
return TextMessageHandler.super.isApplicable(message)
|
||||
&& message.isCommand(); // && message.getText().startsWith("/");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(Message message) {
|
||||
log.info("CommandHandler : {}", message.getText());
|
||||
TextCommandCode commandCode = TextCommandCode.find(message.getText());
|
||||
TextCommandProcessor applicableProcessor = getApplicableProcessor(commandCode);
|
||||
applicableProcessor.process(message);
|
||||
}
|
||||
|
||||
private TextCommandProcessor getApplicableProcessor(TextCommandCode commandCode) {
|
||||
return processors.stream()
|
||||
.filter(e -> e.isApplicable(commandCode))
|
||||
.findFirst()
|
||||
.orElseThrow(() -> new IllegalArgumentException("Can not found"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.myoa.engineering.crawl.ppomppu.reader.handler.message.text;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||
|
||||
import com.myoa.engineering.crawl.ppomppu.reader.handler.message.TextMessageHandler;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* NormalTextHandler
|
||||
* @author Shin Woo-jin (woo-jin.shin@linecorp.com)
|
||||
* @since 2021-08-21
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class CommonTextHandler implements TextMessageHandler {
|
||||
|
||||
@Override
|
||||
public boolean isApplicable(Message message) {
|
||||
return TextMessageHandler.super.isApplicable(message) && message.isCommand() == false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(Message message) {
|
||||
log.info("CommonTextHandler : {}", message.getText());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.myoa.engineering.crawl.ppomppu.reader.handler.message.text;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||
|
||||
/**
|
||||
* EmptyTextCommandProcessor
|
||||
* @author Shin Woo-jin (woo-jin.shin@linecorp.com)
|
||||
* @since 2021-09-05
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
public class EmptyTextCommandProcessor implements TextCommandProcessor {
|
||||
|
||||
@Override
|
||||
public boolean isApplicable(TextCommandCode commandCode) {
|
||||
return commandCode == TextCommandCode.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(Message message) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.myoa.engineering.crawl.ppomppu.reader.handler.message.text;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* StartCommandProcessor
|
||||
* @author Shin Woo-jin (woo-jin.shin@linecorp.com)
|
||||
* @since 2021-09-05
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class StartTextCommandProcessor implements TextCommandProcessor {
|
||||
|
||||
@Override
|
||||
public boolean isApplicable(TextCommandCode commandCode) {
|
||||
return TextCommandCode.START == commandCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(Message message) {
|
||||
log.info("[process] user: {}, command: {}", message.getChatId(), message.getText());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.myoa.engineering.crawl.ppomppu.reader.handler.message.text;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* CommandTextCode
|
||||
* @author Shin Woo-jin (woo-jin.shin@linecorp.com)
|
||||
* @since 2021-09-05
|
||||
*
|
||||
*/
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
public enum TextCommandCode {
|
||||
EMPTY(null),
|
||||
START("/start"),
|
||||
;
|
||||
private String value;
|
||||
|
||||
TextCommandCode(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public static TextCommandCode find(String value) {
|
||||
return Arrays.stream(TextCommandCode.values())
|
||||
.filter(e -> e != EMPTY)
|
||||
.filter(e -> value.startsWith(e.getValue()))
|
||||
.findFirst()
|
||||
.orElse(TextCommandCode.EMPTY);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.myoa.engineering.crawl.ppomppu.reader.handler.message.text;
|
||||
|
||||
import org.telegram.telegrambots.meta.api.objects.Message;
|
||||
|
||||
/**
|
||||
* TextCommandProcessor
|
||||
* @author Shin Woo-jin (woo-jin.shin@linecorp.com)
|
||||
* @since 2021-09-05
|
||||
*
|
||||
*/
|
||||
public interface TextCommandProcessor {
|
||||
|
||||
boolean isApplicable(TextCommandCode commandCode);
|
||||
|
||||
void process(Message message);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.myoa.engineering.crawl.ppomppu.reader.infrastructure.client;
|
||||
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
import org.springframework.web.reactive.function.client.WebClientRequestException;
|
||||
|
||||
import com.myoa.engineering.crawl.ppomppu.reader.dto.constant.WebClientPropertiesUnitName;
|
||||
import com.myoa.engineering.crawl.shopping.support.dto.constant.PpomppuBoardName;
|
||||
import com.myoa.engineering.crawl.shopping.support.webclient.factory.WebClientFilterFactory;
|
||||
import com.myoa.engineering.crawl.shopping.support.webclient.properties.WebClientProperties;
|
||||
import com.myoa.engineering.crawl.shopping.support.webclient.properties.WebClientProperties.WebClientPropertiesUnit;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.core.scheduler.Schedulers;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class ProcessorAPIWebClient {
|
||||
|
||||
private final WebClient webClient;
|
||||
|
||||
public ProcessorAPIWebClient(WebClientProperties webClientProperties) {
|
||||
WebClientPropertiesUnit webClientPropertiesUnit =
|
||||
webClientProperties.find(WebClientPropertiesUnitName.PPOMPPU_NOTIFIER_PROCESSOR_API.getUnitName());
|
||||
this.webClient = WebClient.builder()
|
||||
.baseUrl(webClientPropertiesUnit.getBaseUrl())
|
||||
.filter(WebClientFilterFactory.logRequest())
|
||||
.filter(WebClientFilterFactory.logResponse())
|
||||
.build();
|
||||
}
|
||||
|
||||
public Mono<String> emitParseEvent(PpomppuBoardName boardName) {
|
||||
return webClient.post()
|
||||
.uri("/api/v1/crawl/boards/{boardName}", boardName)
|
||||
.exchangeToMono(e -> e.bodyToMono(new ParameterizedTypeReference<String>() {}))
|
||||
.publishOn(Schedulers.boundedElastic())
|
||||
.onErrorResume(WebClientRequestException.class, t -> {
|
||||
log.info("Exception occured, ignoring. : {}", t.getClass().getSimpleName());
|
||||
return Mono.empty();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.myoa.engineering.crawl.ppomppu.reader.scheduler;
|
||||
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.myoa.engineering.crawl.ppomppu.reader.service.ProcessorAPIService;
|
||||
import com.myoa.engineering.crawl.shopping.support.dto.constant.PpomppuBoardName;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* ParseEventEmitter
|
||||
* @author Shin Woo-jin (woo-jin.shin@linecorp.com)
|
||||
* @since 2021-09-05
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@EnableScheduling
|
||||
public class ParseEventEmitter {
|
||||
|
||||
private final ProcessorAPIService processorAPIService;
|
||||
|
||||
public ParseEventEmitter(ProcessorAPIService processorAPIService) {
|
||||
this.processorAPIService = processorAPIService;
|
||||
}
|
||||
|
||||
@Scheduled(fixedRate = 300 * 1000L)
|
||||
public void emitBoards() {
|
||||
log.info("[emitDomesticBoard] trigger fired!");
|
||||
for (PpomppuBoardName boardName : PpomppuBoardName.values()) {
|
||||
processorAPIService.emitParseEvent(boardName).block();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.myoa.engineering.crawl.ppomppu.reader.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.myoa.engineering.crawl.ppomppu.reader.infrastructure.client.ProcessorAPIWebClient;
|
||||
import com.myoa.engineering.crawl.shopping.support.dto.constant.PpomppuBoardName;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
/**
|
||||
* ProcessorAPIService
|
||||
* @author Shin Woo-jin (woo-jin.shin@linecorp.com)
|
||||
* @since 2021-09-05
|
||||
*
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class ProcessorAPIService {
|
||||
|
||||
private final ProcessorAPIWebClient processorAPIWebClient;
|
||||
|
||||
public ProcessorAPIService(ProcessorAPIWebClient processorAPIWebClient) {
|
||||
this.processorAPIWebClient = processorAPIWebClient;
|
||||
}
|
||||
|
||||
public Mono<String> emitParseEvent(PpomppuBoardName boardName) {
|
||||
return processorAPIWebClient.emitParseEvent(boardName);
|
||||
}
|
||||
}
|
||||
6
reader/src/main/resources/application-development.yml
Normal file
6
reader/src/main/resources/application-development.yml
Normal file
@@ -0,0 +1,6 @@
|
||||
spring:
|
||||
config:
|
||||
activate:
|
||||
on-profile: development
|
||||
import:
|
||||
- "configserver:http://192.168.0.100:11080"
|
||||
6
reader/src/main/resources/application-local.yml
Normal file
6
reader/src/main/resources/application-local.yml
Normal file
@@ -0,0 +1,6 @@
|
||||
spring:
|
||||
config:
|
||||
activate:
|
||||
on-profile: local
|
||||
import:
|
||||
- "configserver:http://localhost:20085"
|
||||
7
reader/src/main/resources/application-production.yml
Normal file
7
reader/src/main/resources/application-production.yml
Normal file
@@ -0,0 +1,7 @@
|
||||
spring:
|
||||
config:
|
||||
activate:
|
||||
on-profile: production
|
||||
import:
|
||||
- classpath:/production/webclient.yml
|
||||
- "configserver:http://ppn-config-server:20080"
|
||||
25
reader/src/main/resources/application.yml
Normal file
25
reader/src/main/resources/application.yml
Normal file
@@ -0,0 +1,25 @@
|
||||
spring:
|
||||
application:
|
||||
name: ppn-receiver
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
profiles:
|
||||
active: ${SPRING_ACTIVE_PROFILE:local}
|
||||
group:
|
||||
local: "local,webclient-local"
|
||||
development: "development,webclient-development"
|
||||
production: "production,webclient-production"
|
||||
freemarker:
|
||||
enabled: false
|
||||
|
||||
server:
|
||||
port: 20080
|
||||
error:
|
||||
whitelabel:
|
||||
enabled: false
|
||||
|
||||
management:
|
||||
endpoints:
|
||||
web:
|
||||
exposure:
|
||||
include: refresh
|
||||
15
reader/src/main/resources/logback-spring.xml
Normal file
15
reader/src/main/resources/logback-spring.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<springProperty name="DEFAULT_LEVEL_CONFIG" source="log.defaultLevel" />
|
||||
<springProfile name="local">
|
||||
<include resource="logback/logback-development.xml" />
|
||||
<logger name="org.apache.kafka" level="INFO" />
|
||||
</springProfile>
|
||||
<springProfile name="development">
|
||||
<include resource="logback/logback-development.xml" />
|
||||
<logger name="org.apache.kafka" level="INFO" />
|
||||
</springProfile>
|
||||
<springProfile name="production">
|
||||
<include resource="logback/logback-production.xml" />
|
||||
</springProfile>
|
||||
</configuration>
|
||||
23
reader/src/main/resources/logback/component/logback-file.xml
Normal file
23
reader/src/main/resources/logback/component/logback-file.xml
Normal file
@@ -0,0 +1,23 @@
|
||||
<included>
|
||||
<property name="FILE_LOG_PATTERN"
|
||||
value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{45}:%L - %msg%n" />
|
||||
<property name="LOG_FILE_BASE" value="lcp-benefit-benefit-api" />
|
||||
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${DIRECTORY}/${LOG_FILE_BASE}_log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>${DIRECTORY}/${LOG_FILE_BASE}_log.%d{yyyyMMdd}.%i</fileNamePattern>
|
||||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
||||
<maxFileSize>1000MB</maxFileSize>
|
||||
</timeBasedFileNamingAndTriggeringPolicy>
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${FILE_LOG_PATTERN}</pattern>
|
||||
<immediateFlush>${IMMEDIATE_FLUSH}</immediateFlush>
|
||||
</encoder>
|
||||
</appender>
|
||||
<appender name="ASYNC_FILE" class="ch.qos.logback.classic.AsyncAppender">
|
||||
<queueSize>1024</queueSize>
|
||||
<appender-ref ref="FILE" />
|
||||
</appender>
|
||||
</included>
|
||||
19
reader/src/main/resources/logback/logback-development.xml
Normal file
19
reader/src/main/resources/logback/logback-development.xml
Normal file
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<included>
|
||||
<!-- =========== property BETA ========= -->
|
||||
<property name="DEFAULT_LEVEL" value="${DEFAULT_LEVEL_CONFIG:-INFO}"/>
|
||||
<!--file-->
|
||||
<property name="DIRECTORY" value="/home1/www/logs/supervisor"/>
|
||||
<property name="IMMEDIATE_FLUSH" value="true"/>
|
||||
<!--nelo2-->
|
||||
<property name="NELO2_LEVEL" value="WARN"/>
|
||||
<!-- =========== include appender =========== -->
|
||||
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
|
||||
<include resource="org/springframework/boot/logging/logback/console-appender.xml"/>
|
||||
<include resource="logback/component/logback-nelo2.xml"/>
|
||||
<include resource="logback/component/logback-datachain.xml"/>
|
||||
<!-- =========== root logger ============== -->
|
||||
<root level="${DEFAULT_LEVEL}">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
</root>
|
||||
</included>
|
||||
19
reader/src/main/resources/logback/logback-production.xml
Normal file
19
reader/src/main/resources/logback/logback-production.xml
Normal file
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<included>
|
||||
<!-- =========== property RELEASE ========= -->
|
||||
<property name="DEFAULT_LEVEL" value="${DEFAULT_LEVEL_CONFIG:-INFO}"/>
|
||||
<!--file-->
|
||||
<property name="DIRECTORY" value="/home1/www/logs/supervisor"/>
|
||||
<property name="IMMEDIATE_FLUSH" value="true"/>
|
||||
<!--nelo2-->
|
||||
<property name="NELO2_LEVEL" value="WARN"/>
|
||||
<!-- =========== include appender =========== -->
|
||||
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
|
||||
<include resource="org/springframework/boot/logging/logback/console-appender.xml"/>
|
||||
<include resource="logback/component/logback-nelo2.xml"/>
|
||||
<include resource="logback/component/logback-datachain.xml"/>
|
||||
<!-- =========== root logger ============== -->
|
||||
<root level="${DEFAULT_LEVEL}">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
</root>
|
||||
</included>
|
||||
Reference in New Issue
Block a user