io.github.hpsocket.soa.starter.web.cloud.config.SoaClouldSentinelConfig Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hp-soa-starter-web-cloud Show documentation
Show all versions of hp-soa-starter-web-cloud Show documentation
hp-soa: a fully functional, easy-to-use, and highly scalable microservice framework
The newest version!
package io.github.hpsocket.soa.starter.web.cloud.config;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import com.alibaba.csp.sentinel.adapter.spring.webmvc_v6x.callback.BlockExceptionHandler;
import io.github.hpsocket.soa.starter.sentinel.config.SoaSentinelConfig;
import io.github.hpsocket.soa.starter.web.cloud.advice.CloudSentinelExceptionAdvice;
import io.github.hpsocket.soa.starter.web.cloud.exception.CloudSentinelBlockExceptionHandler;
/** HP-SOA Spring Cloud Sentinel 配置 */
@AutoConfiguration(before = SoaSentinelConfig.class)
@ConditionalOnClass(SoaSentinelConfig.class)
public class SoaClouldSentinelConfig
{
public static final String sentinelExceptionAdviceBeanName = SoaSentinelConfig.sentinelExceptionAdviceBeanName;
public static final String sentinelBlockExceptionHandlerBeanName = SoaSentinelConfig.sentinelBlockExceptionHandlerBeanName;
@Bean(sentinelExceptionAdviceBeanName)
@ConditionalOnMissingBean(name = sentinelExceptionAdviceBeanName)
CloudSentinelExceptionAdvice sentinelExceptionAdvice()
{
return new CloudSentinelExceptionAdvice();
}
/** 限流处理器 */
@Bean(sentinelBlockExceptionHandlerBeanName)
@ConditionalOnMissingBean(name = sentinelBlockExceptionHandlerBeanName)
@ConditionalOnProperty(name = "spring.cloud.sentinel.filter.enabled", matchIfMissing = true)
BlockExceptionHandler sentinelBlockExceptionHandler()
{
return new CloudSentinelBlockExceptionHandler();
}
}