32 lines
1.2 KiB
Java
32 lines
1.2 KiB
Java
package com.myoa.engineering.crawl.ppomppu.receiver.infrastructure.client;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.core.ParameterizedTypeReference;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.web.reactive.function.client.WebClient;
|
|
|
|
import com.myoa.engineering.crawl.ppomppu.support.dto.code.PpomppuBoardName;
|
|
|
|
import reactor.core.publisher.Mono;
|
|
import reactor.core.scheduler.Schedulers;
|
|
|
|
@Component
|
|
public class ProcessorAPIWebClient {
|
|
|
|
@Value("${webclient.base-url}")
|
|
private String baseUrl;
|
|
|
|
private final WebClient webClient;
|
|
|
|
public ProcessorAPIWebClient(WebClient.Builder webClientBuilder) {
|
|
this.webClient = webClientBuilder.baseUrl("http://localhost:20081")
|
|
.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());
|
|
}
|
|
} |