package com.gyee.runeconomy.util.realtimesource.feign;


import com.gyee.runeconomy.config.GyeeConfig;
import feign.Feign;
import feign.Request;
import feign.Retryer;
import feign.jackson.JacksonDecoder;
import feign.jackson.JacksonEncoder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;


/**
 * @author xysn
 */

@Configuration
public class FeignsBuilder {

    @Resource
    private GyeeConfig config;

    @Bean
    public IDataAdapter dataAdapter() {
        return Feign.builder()
                .encoder(new JacksonEncoder())
                .decoder(new JacksonDecoder())
                .options(new Request.Options(1000, 100000))
                .retryer(new Retryer.Default(5000, 5000, 3))
                .target(IDataAdapter.class, config.getAdapterfdUrl());
    }
}
