package com.bawei.es.remote.factory;

import com.bawei.common.core.domain.R;
import com.bawei.es.remote.api.RemoteIndexService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * 文件服务降级处理
 *
 * @author bawei
 */
@Component
public class RemoteIndexFallbackFactory implements FallbackFactory<RemoteIndexService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteIndexFallbackFactory.class);


    @Override
    public RemoteIndexService create(Throwable cause) {
        return new RemoteIndexService() {
            @Override
            public R exist(String indexName) {
                return R.fail();
            }

            @Override
            public R getMapping(String indexName) {
                return R.fail();
            }

            @Override
            public R index(String indexName, Map<String, Object> mappings) {
                return R.fail();
            }

            @Override
            public R updateIndex(String indexName, Map<String, Object> mappings) {
                return R.fail();
            }

            @Override
            public R deleteIndex(String indexName) {
                return R.fail();
            }
        };
    }
}
