Skip to content

Commit

Permalink
Merge pull request #35 from hengboy/2.3.x
Browse files Browse the repository at this point in the history
Adapt "minbox-ratelimiter" component
  • Loading branch information
hengboy authored Jul 21, 2020
2 parents 3fcda1f + 56c262c commit c955c17
Show file tree
Hide file tree
Showing 43 changed files with 72 additions and 2,693 deletions.
10 changes: 10 additions & 0 deletions api-boot-project/api-boot-autoconfigure/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,16 @@
<artifactId>minbox-mongo-client-settings</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.minbox.framework</groupId>
<artifactId>minbox-ratelimiter</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.minbox.framework</groupId>
<artifactId>minbox-resource-load</artifactId>
<optional>true</optional>
</dependency>

<!--Others-->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@

package org.minbox.framework.api.boot.autoconfigure.ratelimiter;

import org.minbox.framework.api.boot.limiter.ApiBootRateLimiter;
import org.minbox.framework.api.boot.limiter.aop.advisor.ApiBootRateLimiterAdvisor;
import org.minbox.framework.api.boot.limiter.aop.interceptor.ApiBootRateLimiterMethodInterceptor;
import org.minbox.framework.api.boot.limiter.centre.RateLimiterConfigCentre;
import org.minbox.framework.api.boot.limiter.centre.support.DefaultRateLimiterConfigCentre;
import org.minbox.framework.api.boot.limiter.result.RateLimiterOverFlowResponse;
import org.minbox.framework.api.boot.limiter.support.GoogleGuavaRateLimiter;
import org.minbox.framework.limiter.MinBoxRateLimiter;
import org.minbox.framework.limiter.aop.advisor.RateLimiterAdvisor;
import org.minbox.framework.limiter.aop.interceptor.RateLimiterMethodInterceptor;
import org.minbox.framework.limiter.centre.RateLimiterConfigCentre;
import org.minbox.framework.limiter.centre.support.DefaultRateLimiterConfigCentre;
import org.minbox.framework.limiter.result.RateLimiterOverFlowResponse;
import org.minbox.framework.limiter.support.GoogleGuavaRateLimiter;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
Expand All @@ -41,7 +41,7 @@
* @author 恒宇少年
*/
@Configuration
@ConditionalOnClass(ApiBootRateLimiter.class)
@ConditionalOnClass(MinBoxRateLimiter.class)
@EnableConfigurationProperties(ApiBootRateLimiterProperties.class)
@AutoConfigureAfter(WebMvcAutoConfiguration.class)
@Import({ApiBootRateLimiterRedisAutoConfiguration.class, ApiBootRateLimiterNacosConfigConfiguration.class})
Expand Down Expand Up @@ -69,7 +69,7 @@ public ApiBootRateLimiterAutoConfiguration(ApiBootRateLimiterProperties apiBootR
@Bean
@ConditionalOnMissingBean
@ConditionalOnMissingClass("org.springframework.data.redis.core.RedisTemplate")
public ApiBootRateLimiter googleGuavaRateLimiter(RateLimiterConfigCentre rateLimiterConfigCentre) {
public MinBoxRateLimiter googleGuavaRateLimiter(RateLimiterConfigCentre rateLimiterConfigCentre) {
return new GoogleGuavaRateLimiter(apiBootRateLimiterProperties.isEnableGlobalQps() ? apiBootRateLimiterProperties.getGlobalQps() : 0L, rateLimiterConfigCentre);
}

Expand All @@ -88,13 +88,13 @@ public RateLimiterConfigCentre defaultRateLimiterConfigCentre() {
/**
* ApiBoot RateLimiter Pointcut Advisor
*
* @param apiBootRateLimiterMethodInterceptor ResourceLoad Annotation Method Interceptor
* @param rateLimiterMethodInterceptor ResourceLoad Annotation Method Interceptor
* @return ApiBootRateLimiterAdvisor
*/
@Bean
@ConditionalOnMissingBean
ApiBootRateLimiterAdvisor rateLimiterAdvisor(ApiBootRateLimiterMethodInterceptor apiBootRateLimiterMethodInterceptor) {
return new ApiBootRateLimiterAdvisor(apiBootRateLimiterMethodInterceptor);
RateLimiterAdvisor rateLimiterAdvisor(RateLimiterMethodInterceptor rateLimiterMethodInterceptor) {
return new RateLimiterAdvisor(rateLimiterMethodInterceptor);
}

/**
Expand All @@ -106,7 +106,7 @@ ApiBootRateLimiterAdvisor rateLimiterAdvisor(ApiBootRateLimiterMethodInterceptor
*/
@Bean
@ConditionalOnMissingBean
ApiBootRateLimiterMethodInterceptor rateLimiterMethodInterceptor(ApiBootRateLimiter apiBootRateLimiter) {
return new ApiBootRateLimiterMethodInterceptor(apiBootRateLimiter, rateLimiterOverFlowResponse);
RateLimiterMethodInterceptor rateLimiterMethodInterceptor(MinBoxRateLimiter apiBootRateLimiter) {
return new RateLimiterMethodInterceptor(apiBootRateLimiter, rateLimiterOverFlowResponse);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import com.alibaba.nacos.api.NacosFactory;
import com.alibaba.nacos.api.config.ConfigService;
import com.alibaba.nacos.api.exception.NacosException;
import org.minbox.framework.api.boot.limiter.centre.RateLimiterConfigCentre;
import org.minbox.framework.api.boot.limiter.centre.support.NacosRateLimiterConfigCentre;
import org.minbox.framework.limiter.centre.RateLimiterConfigCentre;
import org.minbox.framework.limiter.centre.support.NacosRateLimiterConfigCentre;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Qualifier;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
*/

package org.minbox.framework.api.boot.autoconfigure.ratelimiter;
import org.minbox.framework.api.boot.limiter.ApiBootRateLimiter;
import org.minbox.framework.api.boot.limiter.centre.RateLimiterConfigCentre;
import org.minbox.framework.api.boot.limiter.support.RedisLuaRateLimiter;
import org.minbox.framework.limiter.MinBoxRateLimiter;
import org.minbox.framework.limiter.centre.RateLimiterConfigCentre;
import org.minbox.framework.limiter.support.RedisLuaRateLimiter;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
Expand Down Expand Up @@ -56,7 +56,7 @@ public ApiBootRateLimiterRedisAutoConfiguration(ApiBootRateLimiterProperties api
*/
@Bean
@ConditionalOnMissingBean
public ApiBootRateLimiter redisLuaRateLimiter(RedisTemplate redisTemplate, RateLimiterConfigCentre rateLimiterConfigCentre) {
public MinBoxRateLimiter redisLuaRateLimiter(RedisTemplate redisTemplate, RateLimiterConfigCentre rateLimiterConfigCentre) {
return new RedisLuaRateLimiter(apiBootRateLimiterProperties.isEnableGlobalQps() ? apiBootRateLimiterProperties.getGlobalQps() : 0L, rateLimiterConfigCentre, redisTemplate);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
*/
package org.minbox.framework.api.boot.autoconfigure.resource;

import org.minbox.framework.api.boot.resource.ApiBootResourceStoreDelegate;
import org.minbox.framework.api.boot.resource.aop.advistor.ApiBootResourceLoadAdvisor;
import org.minbox.framework.api.boot.resource.aop.interceptor.ApiBootResourceLoadMethodInterceptor;
import org.minbox.framework.api.boot.resource.pusher.ApiBootResourcePusher;
import org.minbox.framework.api.boot.resource.pusher.support.ApiBootMemoryResourcePusher;
import org.minbox.framework.resource.ResourceStoreDelegate;
import org.minbox.framework.resource.aop.advistor.ResourceLoadAdvisor;
import org.minbox.framework.resource.aop.interceptor.ResourceLoadMethodInterceptor;
import org.minbox.framework.resource.pusher.ResourcePusher;
import org.minbox.framework.resource.pusher.support.MemoryResourcePusher;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
Expand All @@ -35,15 +35,15 @@
* @author 恒宇少年
*/
@Configuration
@ConditionalOnClass(ApiBootResourceStoreDelegate.class)
@ConditionalOnClass(ResourceStoreDelegate.class)
@Import(ApiBootResourceRedisLoadAutoConfiguration.class)
public class ApiBootResourceLoadAutoConfiguration {
/**
* ApiBoot Resource Load Store Delegate
*/
private ApiBootResourceStoreDelegate resourceStoreDelegate;
private ResourceStoreDelegate resourceStoreDelegate;

public ApiBootResourceLoadAutoConfiguration(ObjectProvider<ApiBootResourceStoreDelegate> resourceStoreDelegateObjectProvider) {
public ApiBootResourceLoadAutoConfiguration(ObjectProvider<ResourceStoreDelegate> resourceStoreDelegateObjectProvider) {
this.resourceStoreDelegate = resourceStoreDelegateObjectProvider.getIfAvailable();
}

Expand All @@ -55,8 +55,8 @@ public ApiBootResourceLoadAutoConfiguration(ObjectProvider<ApiBootResourceStoreD
*/
@Bean
@ConditionalOnMissingBean
ApiBootResourceLoadAdvisor resourceLoadAdvisor(ApiBootResourceLoadMethodInterceptor resourceLoadMethodInterceptor) {
return new ApiBootResourceLoadAdvisor(resourceLoadMethodInterceptor);
ResourceLoadAdvisor resourceLoadAdvisor(ResourceLoadMethodInterceptor resourceLoadMethodInterceptor) {
return new ResourceLoadAdvisor(resourceLoadMethodInterceptor);
}

/**
Expand All @@ -67,8 +67,8 @@ ApiBootResourceLoadAdvisor resourceLoadAdvisor(ApiBootResourceLoadMethodIntercep
*/
@Bean
@ConditionalOnMissingBean
ApiBootResourceLoadMethodInterceptor resourceLoadMethodInterceptor(ApiBootResourcePusher apiBootResourcePusher) {
return new ApiBootResourceLoadMethodInterceptor(apiBootResourcePusher);
ResourceLoadMethodInterceptor resourceLoadMethodInterceptor(ResourcePusher apiBootResourcePusher) {
return new ResourceLoadMethodInterceptor(apiBootResourcePusher);
}

/**
Expand All @@ -80,7 +80,7 @@ ApiBootResourceLoadMethodInterceptor resourceLoadMethodInterceptor(ApiBootResour
@Bean
@ConditionalOnMissingBean
@ConditionalOnMissingClass("org.springframework.data.redis.core.RedisTemplate")
ApiBootMemoryResourcePusher apiBootMemoryResourcePusher() {
return new ApiBootMemoryResourcePusher(resourceStoreDelegate);
MemoryResourcePusher apiBootMemoryResourcePusher() {
return new MemoryResourcePusher(resourceStoreDelegate);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

package org.minbox.framework.api.boot.autoconfigure.resource;

import org.minbox.framework.api.boot.resource.ApiBootResourceStoreDelegate;
import org.minbox.framework.api.boot.resource.pusher.support.ApiBootRedisResourcePusher;
import org.minbox.framework.resource.ResourceStoreDelegate;
import org.minbox.framework.resource.pusher.support.RedisResourcePusher;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
Expand All @@ -40,9 +40,9 @@ public class ApiBootResourceRedisLoadAutoConfiguration {
/**
* ApiBoot Resource Load Store Delegate
*/
private ApiBootResourceStoreDelegate resourceStoreDelegate;
private ResourceStoreDelegate resourceStoreDelegate;

public ApiBootResourceRedisLoadAutoConfiguration(ObjectProvider<ApiBootResourceStoreDelegate> resourceStoreDelegateObjectProvider) {
public ApiBootResourceRedisLoadAutoConfiguration(ObjectProvider<ResourceStoreDelegate> resourceStoreDelegateObjectProvider) {
this.resourceStoreDelegate = resourceStoreDelegateObjectProvider.getIfAvailable();
}

Expand All @@ -54,7 +54,7 @@ public ApiBootResourceRedisLoadAutoConfiguration(ObjectProvider<ApiBootResourceS
*/
@Bean
@ConditionalOnMissingBean
ApiBootRedisResourcePusher apiBootRedisResourcePusher(RedisTemplate redisTemplate) {
return new ApiBootRedisResourcePusher(resourceStoreDelegate, redisTemplate);
RedisResourcePusher apiBootRedisResourcePusher(RedisTemplate redisTemplate) {
return new RedisResourcePusher(resourceStoreDelegate, redisTemplate);
}
}
12 changes: 12 additions & 0 deletions api-boot-project/api-boot-dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
<!--Minbox Projects-->
<minbox.version>1.0.5.RELEASE</minbox.version>
<minbox-logging.version>1.0.5.RELEASE</minbox-logging.version>
<minbox-ratelimiter.version>1.0.0.RELEASE</minbox-ratelimiter.version>
<minbox-resource-load.version>1.0.0.RELEASE</minbox-resource-load.version>
<minbox-mongo-client-settings.version>1.0.0.RELEASE</minbox-mongo-client-settings.version>
<code.builder.core.version>1.0.5.RELEASE</code.builder.core.version>
<mybatis-enhance.version>1.1.3.RELEASE</mybatis-enhance.version>
Expand Down Expand Up @@ -164,6 +166,16 @@
<artifactId>mybatis-enhance-dsl</artifactId>
<version>${mybatis-enhance.version}</version>
</dependency>
<dependency>
<groupId>org.minbox.framework</groupId>
<artifactId>minbox-ratelimiter</artifactId>
<version>${minbox-ratelimiter.version}</version>
</dependency>
<dependency>
<groupId>org.minbox.framework</groupId>
<artifactId>minbox-resource-load</artifactId>
<version>${minbox-resource-load.version}</version>
</dependency>


<!--ApiBoot Dependencies-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
<groupId>org.minbox.framework</groupId>
<artifactId>api-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.minbox.framework</groupId>
<artifactId>minbox-ratelimiter</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@
<groupId>org.minbox.framework</groupId>
<artifactId>api-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.minbox.framework</groupId>
<artifactId>minbox-resource-load</artifactId>
</dependency>
<!--SpringBoot Aop-->
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit c955c17

Please sign in to comment.