Feign 스레드의 인스턴스가 안전합니까 ...? 이 문제를 지원하는 문서를 찾을 수 없습니다. 밖에서 다른 사람이 그렇게 생각합니까?Feign threadsafe ...가 맞습니까?
다음표준 예 척하기위한 GitHub의의의 repo에 게시 ...
interface GitHub {
@RequestLine("GET /repos/{owner}/{repo}/contributors")
List<Contributor> contributors(@Param("owner") String owner, @Param("repo") String repo);
}
static class Contributor {
String login;
int contributions;
}
public static void main(String... args) {
GitHub github = Feign.builder()
.decoder(new GsonDecoder())
.target(GitHub.class, "https://api.github.com");
// Fetch and print a list of the contributors to this library.
List<Contributor> contributors = github.contributors("netflix", "feign");
for (Contributor contributor : contributors) {
System.out.println(contributor.login + " (" + contributor.contributions + ")");
}
}
내가 다음으로 변경해야 ...는 스레드 안전인가 ...?
interface GitHub {
@RequestLine("GET /repos/{owner}/{repo}/contributors")
List<Contributor> contributors(@Param("owner") String owner, @Param("repo") String repo);
}
static class Contributor {
String login;
int contributions;
}
@Component
public class GithubService {
GitHub github = null;
@PostConstruct
public void postConstruct() {
github = Feign.builder()
.decoder(new GsonDecoder())
.target(GitHub.class, "https://api.github.com");
}
public void callMeForEveryRequest() {
github.contributors... // Is this thread-safe...?
}
}
위의 예제에서는 ... 나는 싱글 톤을 강조하기 위해 스프링 기반 구성 요소를 사용했습니다. 미리 감사드립니다 ...
빌더가 프로토 타입 인 것은 당연하다고 생각하십니까? 빌더의 목표는 속성을 비 원자 적으로 설정하여 새로운 불변 객체를 만드는 것입니다. 빌드되는 객체는 불변, 최종 및 스레드 세이프 일 수 있습니다. – Seagull