package com.gyee.alarm.feigns;

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

/**
 * @author xysn
 */
@Configuration
public class FeignsBuilder {

    /**
     * 推荐url
     */
    @Value("${urls.alarm-service: http://127.0.0.1:6011}")
    private String alarmServiceUrl;

    @Bean
    public IAlarmService shardingService() {
        return Feign.builder()
                .encoder(new JacksonEncoder())
                .decoder(new JacksonDecoder())
                .options(new Request.Options(1000, 900000))
                //.retryer(new Retryer.Default(5000, 5000, 3))
                .target(IAlarmService.class, alarmServiceUrl);
    }
}
