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 lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;


@Slf4j
@Component
public class RemoteServiceBuilder {

    @Resource
    private GyeeConfig config;

    @Bean
    public IAdapterService adapterfd() {
        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, config.getAdapterfdUrl());
    }

    public IAdapterService adaptergf() {
        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, config.getAdaptergfUrl());
    }


    public IAdapterService taos() {
        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, config.getTaosUrl());
    }
}