-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: gateway reactive open feign 설정으로 변경
- Loading branch information
1 parent
ed50ff7
commit 659d406
Showing
1 changed file
with
15 additions
and
27 deletions.
There are no files selected for viewing
42 changes: 15 additions & 27 deletions
42
src/backend/gateway-server/src/main/java/com/lalala/gateway/config/OpenFeignConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |