Skip to content

Commit

Permalink
feat: gateway reactive open feign 설정으로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
kor-Chipmunk committed Feb 18, 2024
1 parent ed50ff7 commit 659d406
Showing 1 changed file with 15 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -1,40 +1,28 @@
package com.lalala.gateway.config;

import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.cloud.openfeign.FeignFormatterRegistrar;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.format.datetime.standard.DateTimeFormatterRegistrar;

import feign.Logger;
import feign.Retryer;
import com.lalala.gateway.external.feign.FeignAuthClient;
import feign.Logger.Level;
import feign.gson.GsonDecoder;
import feign.gson.GsonEncoder;
import feign.reactive.ReactorDecoder;
import feign.reactive.ReactorFeign;

@Configuration
@EnableFeignClients("com.lalala.gateway.external.feign")
public class OpenFeignConfig {

private static final long START_PERIOD = 100L;
private static final long MAX_PERIOD = 3_000L;
private static final int MAX_ATTEMPTS = 5;
@Value("${auth.url}")
private String authEndPoint;

@Bean
Retryer.Default retryer() {
return new Retryer.Default(START_PERIOD, MAX_PERIOD, MAX_ATTEMPTS);
}

@Bean
Logger.Level feignLoggerLevel() {
// Feign 은 debug 레벨로만 로그를 남깁니다.
// loggin.level.com.lalala.gateway.external.feign=DEBUG
return Logger.Level.FULL;
}

@Bean
public FeignFormatterRegistrar dateTimeFormatterRegistrar() {
return registry -> {
DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar();
registrar.setUseIsoFormat(true);
registrar.registerFormatters(registry);
};
public FeignAuthClient authClient() {
return ReactorFeign.builder()
.logLevel(Level.FULL)
.encoder(new GsonEncoder())
.decoder(new ReactorDecoder(new GsonDecoder()))
.target(FeignAuthClient.class, authEndPoint);
}
}

0 comments on commit 659d406

Please sign in to comment.