com.huawei.discovery.retry.config.DefaultRetryConfig Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of springboot-registry-plugin Show documentation
Show all versions of springboot-registry-plugin Show documentation
The plugin module of registry from springboot
/*
* Copyright (C) 2022-2022 Huawei Technologies Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.huawei.discovery.retry.config;
import com.huawei.discovery.config.LbConfig;
import com.huaweicloud.sermant.core.plugin.config.PluginConfigManager;
import java.net.ConnectException;
import java.net.NoRouteToHostException;
import java.net.SocketTimeoutException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeoutException;
import java.util.function.Function;
import java.util.function.Predicate;
/**
* 重试默认配置, 会基于配置文件或者环境变量进行自定义
*
* @author zhouss
* @since 2022-09-28
*/
public class DefaultRetryConfig implements RetryConfig {
private static final String SOCKET_CONNECT_TIMEOUT = "connect timed out";
private static final String SOCKET_READ_TIMEOUT = "Read timed out";
private static final String NAME = "SERMANT_DEFAULT_RETRY";
private final List> retryEx = Arrays.asList(
ConnectException.class,
NoRouteToHostException.class,
SocketTimeoutException.class,
TimeoutException.class);
private final List rawRetryEx = Collections.singletonList(
"org.apache.http.conn.ConnectTimeoutException");
/**
* 最大重试次数
*/
private int maxRetry;
/**
* 配置名称
*/
private String name;
/**
* 异常判断
*/
private Predicate throwablePredicate;
/**
* 结果判断
*/
private Predicate