mirror of
https://gitee.com/mirrors/Spring-Cloud-Alibaba.git
synced 2021-06-26 13:25:11 +08:00
remote all hystrix,zuul,ribbon
This commit is contained in:
@@ -33,11 +33,6 @@
|
||||
<artifactId>sentinel-parameter-flow-control</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba.csp</groupId>
|
||||
<artifactId>sentinel-zuul-adapter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba.csp</groupId>
|
||||
<artifactId>sentinel-spring-cloud-gateway-adapter</artifactId>
|
||||
|
@@ -17,28 +17,17 @@
|
||||
package com.alibaba.cloud.sentinel.gateway;
|
||||
|
||||
import com.alibaba.cloud.sentinel.gateway.scg.SentinelGatewayProperties;
|
||||
import com.alibaba.cloud.sentinel.gateway.zuul.SentinelZuulProperties;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:fangjian0423@gmail.com">Jim</a>
|
||||
*/
|
||||
public final class ConfigConstants {
|
||||
|
||||
/**
|
||||
* Netflix Zuul type.
|
||||
*/
|
||||
public static final String APP_TYPE_ZUUL_GATEWAY = "12";
|
||||
|
||||
/**
|
||||
* Spring Cloud Gateway type.
|
||||
*/
|
||||
public static final String APP_TYPE_SCG_GATEWAY = "11";
|
||||
|
||||
/**
|
||||
* ConfigurationProperties for {@link SentinelZuulProperties}.
|
||||
*/
|
||||
public static final String ZUUL_PREFIX = "spring.cloud.sentinel.zuul";
|
||||
|
||||
/**
|
||||
* ConfigurationProperties for {@link SentinelGatewayProperties}.
|
||||
*/
|
||||
|
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* https://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.alibaba.cloud.sentinel.gateway.zuul;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.alibaba.csp.sentinel.adapter.gateway.zuul.fallback.DefaultBlockFallbackProvider;
|
||||
import com.alibaba.csp.sentinel.adapter.gateway.zuul.fallback.ZuulBlockFallbackManager;
|
||||
import com.alibaba.csp.sentinel.adapter.gateway.zuul.fallback.ZuulBlockFallbackProvider;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.beans.factory.SmartInitializingSingleton;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
/**
|
||||
* @author tiger
|
||||
*/
|
||||
public class FallBackProviderHandler implements SmartInitializingSingleton {
|
||||
|
||||
private static final Logger logger = LoggerFactory
|
||||
.getLogger(FallBackProviderHandler.class);
|
||||
|
||||
private final DefaultListableBeanFactory beanFactory;
|
||||
|
||||
public FallBackProviderHandler(DefaultListableBeanFactory beanFactory) {
|
||||
this.beanFactory = beanFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterSingletonsInstantiated() {
|
||||
Map<String, ZuulBlockFallbackProvider> providerMap = beanFactory
|
||||
.getBeansOfType(ZuulBlockFallbackProvider.class);
|
||||
if (!CollectionUtils.isEmpty(providerMap)) {
|
||||
providerMap.forEach((k, v) -> {
|
||||
logger.info("[Sentinel Zuul] Register provider name:{}, instance: {}", k,
|
||||
v);
|
||||
ZuulBlockFallbackManager.registerProvider(v);
|
||||
});
|
||||
}
|
||||
else {
|
||||
logger.info("[Sentinel Zuul] Register default fallback provider. ");
|
||||
ZuulBlockFallbackManager.registerProvider(new DefaultBlockFallbackProvider());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,102 +0,0 @@
|
||||
///*
|
||||
// * Copyright 2013-2018 the original author or authors.
|
||||
// *
|
||||
// * 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
|
||||
// *
|
||||
// * https://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.alibaba.cloud.sentinel.gateway.zuul;
|
||||
//
|
||||
//import java.util.Optional;
|
||||
//
|
||||
//import javax.annotation.PostConstruct;
|
||||
//
|
||||
//import com.alibaba.cloud.sentinel.gateway.ConfigConstants;
|
||||
//import com.alibaba.csp.sentinel.adapter.gateway.zuul.callback.RequestOriginParser;
|
||||
//import com.alibaba.csp.sentinel.adapter.gateway.zuul.callback.ZuulGatewayCallbackManager;
|
||||
//import com.alibaba.csp.sentinel.adapter.gateway.zuul.filters.SentinelZuulErrorFilter;
|
||||
//import com.alibaba.csp.sentinel.adapter.gateway.zuul.filters.SentinelZuulPostFilter;
|
||||
//import com.alibaba.csp.sentinel.adapter.gateway.zuul.filters.SentinelZuulPreFilter;
|
||||
//import com.alibaba.csp.sentinel.config.SentinelConfig;
|
||||
//import com.netflix.zuul.http.ZuulServlet;
|
||||
//import org.slf4j.Logger;
|
||||
//import org.slf4j.LoggerFactory;
|
||||
//
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
//import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
//import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
//import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
//import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
//import org.springframework.context.annotation.Bean;
|
||||
//import org.springframework.context.annotation.Configuration;
|
||||
//
|
||||
///**
|
||||
// * Sentinel Spring Cloud Zuul AutoConfiguration.
|
||||
// *
|
||||
// * @author tiger
|
||||
// */
|
||||
//@Configuration(proxyBeanMethods = false)
|
||||
//@ConditionalOnClass(ZuulServlet.class)
|
||||
//@ConditionalOnProperty(prefix = ConfigConstants.ZUUL_PREFIX, name = "enabled",
|
||||
// havingValue = "true", matchIfMissing = true)
|
||||
//@EnableConfigurationProperties(SentinelZuulProperties.class)
|
||||
//public class SentinelZuulAutoConfiguration {
|
||||
//
|
||||
// private static final Logger logger = LoggerFactory
|
||||
// .getLogger(SentinelZuulAutoConfiguration.class);
|
||||
//
|
||||
// @Autowired
|
||||
// private Optional<RequestOriginParser> requestOriginParserOptional;
|
||||
//
|
||||
// @Autowired
|
||||
// private SentinelZuulProperties zuulProperties;
|
||||
//
|
||||
// @PostConstruct
|
||||
// private void init() {
|
||||
// requestOriginParserOptional
|
||||
// .ifPresent(ZuulGatewayCallbackManager::setOriginParser);
|
||||
// System.setProperty(SentinelConfig.APP_TYPE_PROP_KEY,
|
||||
// String.valueOf(ConfigConstants.APP_TYPE_ZUUL_GATEWAY));
|
||||
// }
|
||||
//
|
||||
// @Bean
|
||||
// @ConditionalOnMissingBean
|
||||
// public SentinelZuulPreFilter sentinelZuulPreFilter() {
|
||||
// logger.info("[Sentinel Zuul] register SentinelZuulPreFilter {}",
|
||||
// zuulProperties.getOrder().getPre());
|
||||
// return new SentinelZuulPreFilter(zuulProperties.getOrder().getPre());
|
||||
// }
|
||||
//
|
||||
// @Bean
|
||||
// @ConditionalOnMissingBean
|
||||
// public SentinelZuulPostFilter sentinelZuulPostFilter() {
|
||||
// logger.info("[Sentinel Zuul] register SentinelZuulPostFilter {}",
|
||||
// zuulProperties.getOrder().getPost());
|
||||
// return new SentinelZuulPostFilter(zuulProperties.getOrder().getPost());
|
||||
// }
|
||||
//
|
||||
// @Bean
|
||||
// @ConditionalOnMissingBean
|
||||
// public SentinelZuulErrorFilter sentinelZuulErrorFilter() {
|
||||
// logger.info("[Sentinel Zuul] register SentinelZuulErrorFilter {}",
|
||||
// zuulProperties.getOrder().getError());
|
||||
// return new SentinelZuulErrorFilter(zuulProperties.getOrder().getError());
|
||||
// }
|
||||
//
|
||||
// @Bean
|
||||
// public FallBackProviderHandler fallBackProviderHandler(
|
||||
// DefaultListableBeanFactory beanFactory) {
|
||||
// return new FallBackProviderHandler(beanFactory);
|
||||
// }
|
||||
//
|
||||
//}
|
@@ -1,89 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* https://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.alibaba.cloud.sentinel.gateway.zuul;
|
||||
|
||||
import com.alibaba.cloud.sentinel.gateway.ConfigConstants;
|
||||
import com.alibaba.csp.sentinel.adapter.gateway.zuul.constants.ZuulConstant;
|
||||
import com.alibaba.csp.sentinel.adapter.gateway.zuul.filters.SentinelZuulErrorFilter;
|
||||
import com.alibaba.csp.sentinel.adapter.gateway.zuul.filters.SentinelZuulPostFilter;
|
||||
import com.alibaba.csp.sentinel.adapter.gateway.zuul.filters.SentinelZuulPreFilter;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.NestedConfigurationProperty;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:fangjian0423@gmail.com">Jim</a>
|
||||
*/
|
||||
@ConfigurationProperties(prefix = ConfigConstants.ZUUL_PREFIX)
|
||||
public class SentinelZuulProperties {
|
||||
|
||||
@NestedConfigurationProperty
|
||||
private SentinelZuulProperties.Order order = new SentinelZuulProperties.Order();
|
||||
|
||||
public Order getOrder() {
|
||||
return order;
|
||||
}
|
||||
|
||||
public SentinelZuulProperties setOrder(Order order) {
|
||||
this.order = order;
|
||||
return this;
|
||||
}
|
||||
|
||||
public static class Order {
|
||||
|
||||
/**
|
||||
* The order of {@link SentinelZuulPreFilter}.
|
||||
*/
|
||||
private int pre = 10000;
|
||||
|
||||
/**
|
||||
* The order of {@link SentinelZuulPostFilter}.
|
||||
*/
|
||||
private int post = ZuulConstant.SEND_RESPONSE_FILTER_ORDER;
|
||||
|
||||
/**
|
||||
* The order of {@link SentinelZuulErrorFilter}.
|
||||
*/
|
||||
private int error = -1;
|
||||
|
||||
public int getPre() {
|
||||
return pre;
|
||||
}
|
||||
|
||||
public void setPre(int pre) {
|
||||
this.pre = pre;
|
||||
}
|
||||
|
||||
public int getPost() {
|
||||
return post;
|
||||
}
|
||||
|
||||
public void setPost(int post) {
|
||||
this.post = post;
|
||||
}
|
||||
|
||||
public int getError() {
|
||||
return error;
|
||||
}
|
||||
|
||||
public void setError(int error) {
|
||||
this.error = error;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user