package com.gyee.frame.common.feign;

import feign.Feign;
import feign.Request;
import feign.Retryer;
import feign.jackson.JacksonDecoder;
import feign.jackson.JacksonEncoder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Slf4j
@Configuration
public class RemoteServiceBuilder {

    @Value("${goldenUrl:http://10.155.32.4:8011}")
    private String shardingUrlString;

    @Bean
    public IAdapterService ShardingService() {
        return Feign.builder()
                .encoder(new JacksonEncoder())
                .decoder(new JacksonDecoder())
                .options(new Request.Options(5000, 600000))
                .retryer(new Retryer.Default(10000, 10000, 3))
                .target(IAdapterService.class, shardingUrlString);
    }
}