Skip to content

Commit

Permalink
minor improvements
Browse files Browse the repository at this point in the history
- add Lombok
- use Bucket4j Java 8 compatible dependencies
- use Spring Boot 2.7.6
  • Loading branch information
MarcGiffing committed Dec 18, 2022
1 parent 3391016 commit e26503f
Show file tree
Hide file tree
Showing 16 changed files with 99 additions and 380 deletions.
1 change: 1 addition & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ https://github.com/vladimir-bukhtoyarov/bucket4j

Project version overview:

* 0.8.0 - Bucket4j 8.1.0 - Spring Boot 2.7.x
* 0.7.0 - Bucket4j 7.5.0 - Spring Boot 2.7.x
* 0.6.1 - Bucket4j 7.0.0 - Spring Boot 2.6.x
* 0.5.0 - Bucket4j 7.0.0 - Spring Boot 2.6.1
Expand Down
30 changes: 26 additions & 4 deletions bucket4j-spring-boot-starter-context/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
<parent>
<groupId>com.giffing.bucket4j.spring.boot.starter</groupId>
<artifactId>bucket4j-spring-boot-starter-parent</artifactId>
<version>${revision}</version>
<version>${revision}</version>
</parent>
<artifactId>bucket4j-spring-boot-starter-context</artifactId>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand All @@ -15,18 +14,41 @@
</dependency>
<dependency>
<groupId>com.bucket4j</groupId>
<artifactId>bucket4j-core</artifactId>
<artifactId>bucket4j_jdk8-core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.bucket4j</groupId>
<artifactId>bucket4j-jcache</artifactId>
<artifactId>bucket4j_jdk8-jcache</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.24</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

import com.giffing.bucket4j.spring.boot.starter.context.properties.Bucket4JConfiguration;

import lombok.Data;

@Data
public class Bucket4jConfigurationHolder {

private List<Bucket4JConfiguration> filterConfiguration = new ArrayList<>();
Expand All @@ -13,12 +16,4 @@ public void addFilterConfiguration(Bucket4JConfiguration filterConfiguration) {
getFilterConfiguration().add(filterConfiguration);
}

public List<Bucket4JConfiguration> getFilterConfiguration() {
return filterConfiguration;
}

public void setFilterConfiguration(List<Bucket4JConfiguration> filterConfiguration) {
this.filterConfiguration = filterConfiguration;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
import java.util.concurrent.CompletableFuture;

import io.github.bucket4j.ConsumptionProbe;
import lombok.Data;


@Data
public class ConsumptionProbeHolder {

private ConsumptionProbe consumptionProbe;
Expand All @@ -18,23 +21,4 @@ public ConsumptionProbeHolder(CompletableFuture<ConsumptionProbe> consumptionPro
this.consumptionProbeCompletableFuture = consumptionProbeCompletableFuture;
}

public ConsumptionProbe getConsumptionProbe() {
return consumptionProbe;
}

public void setConsumptionProbe(ConsumptionProbe consumptionProbe) {
this.consumptionProbe = consumptionProbe;
}

public CompletableFuture<ConsumptionProbe> getConsumptionProbeCompletableFuture() {
return consumptionProbeCompletableFuture;
}

public void setConsumptionProbeCompletableFuture(
CompletableFuture<ConsumptionProbe> consumptionProbeCompletableFuture) {
this.consumptionProbeCompletableFuture = consumptionProbeCompletableFuture;
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import java.util.List;

import lombok.Data;

@Data
public class MetricTagResult {

private String key;
Expand All @@ -16,28 +19,4 @@ public MetricTagResult(String key, String value, List<MetricType> types) {
this.setTypes(types);
}

public String getKey() {
return key;
}

public void setKey(String key) {
this.key = key;
}

public String getValue() {
return value;
}

public void setValue(String value) {
this.value = value;
}

public List<MetricType> getTypes() {
return types;
}

public void setTypes(List<MetricType> types) {
this.types = types;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,20 @@

import java.time.temporal.ChronoUnit;

import lombok.Data;

/**
* Configures the rate of data which should be transfered
*
*/
@Data
public class BandWidth {

private long capacity;
private long time;
private ChronoUnit unit;

private long fixedRefillInterval = 0;;
private long fixedRefillInterval = 0;
private ChronoUnit fixedRefillIntervalUnit = ChronoUnit.MINUTES;

public long getCapacity() {
return capacity;
}
public void setCapacity(long capacity) {
this.capacity = capacity;
}
public long getTime() {
return time;
}
public void setTime(long time) {
this.time = time;
}
public ChronoUnit getUnit() {
return unit;
}
public void setUnit(ChronoUnit unit) {
this.unit = unit;
}
public long getFixedRefillInterval() {
return fixedRefillInterval;
}
public void setFixedRefillInterval(long fixedRefillInterval) {
this.fixedRefillInterval = fixedRefillInterval;
}
public ChronoUnit getFixedRefillIntervalUnit() {
return fixedRefillIntervalUnit;
}
public void setFixedRefillIntervalUnit(ChronoUnit fixedRefillIntervalUnit) {
this.fixedRefillIntervalUnit = fixedRefillIntervalUnit;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@

import org.springframework.boot.context.properties.ConfigurationProperties;

import lombok.Data;

/**
* Holds all the relevant starter properties which can be configured with
* Spring Boots application.properties / application.yml configuration files.
*/
@Data
@ConfigurationProperties(prefix = Bucket4JBootProperties.PROPERTY_PREFIX)
public class Bucket4JBootProperties {

Expand Down Expand Up @@ -39,40 +42,9 @@ public class Bucket4JBootProperties {
*/
private List<MetricTag> defaultMetricTags = new ArrayList<>();

public Boolean getEnabled() {
return enabled;
}

public void setEnabled(Boolean enabled) {
this.enabled = enabled;
}


public static String getPropertyPrefix() {
return PROPERTY_PREFIX;
}

public List<Bucket4JConfiguration> getFilters() {
return filters;
}

public void setFilters(List<Bucket4JConfiguration> filters) {
this.filters = filters;
}

public List<MetricTag> getDefaultMetricTags() {
return defaultMetricTags;
}

public void setDefaultMetricTags(List<MetricTag> defaultMetricTags) {
this.defaultMetricTags = defaultMetricTags;
}

public String getCacheToUse() {
return cacheToUse;
}

public void setCacheToUse(String cacheToUse) {
this.cacheToUse = cacheToUse;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
import com.giffing.bucket4j.spring.boot.starter.context.FilterMethod;
import com.giffing.bucket4j.spring.boot.starter.context.RateLimitConditionMatchingStrategy;

import lombok.Data;

@Data
public class Bucket4JConfiguration {

/**
Expand Down Expand Up @@ -63,95 +66,4 @@ public class Bucket4JConfiguration {

private Map<String, String> httpResponseHeaders = new HashMap<>();

public Bucket4JConfiguration() {
}

public String getCacheName() {
return cacheName;
}

public void setCacheName(String cacheName) {
this.cacheName = cacheName;
}

public String getUrl() {
return url;
}

public void setUrl(String url) {
this.url = url;
}

public int getFilterOrder() {
return filterOrder;
}

public void setFilterOrder(int filterOrder) {
this.filterOrder = filterOrder;
}

public FilterMethod getFilterMethod() {
return filterMethod;
}

public void setFilterMethod(FilterMethod filterMethod) {
this.filterMethod = filterMethod;
}

public List<RateLimit> getRateLimits() {
return rateLimits;
}

public void setRateLimits(List<RateLimit> rateLimits) {
this.rateLimits = rateLimits;
}

public RateLimitConditionMatchingStrategy getStrategy() {
return strategy;
}

public void setStrategy(RateLimitConditionMatchingStrategy strategy) {
this.strategy = strategy;
}

public String getHttpResponseBody() {
return httpResponseBody;
}

public void setHttpResponseBody(String httpResponseBody) {
this.httpResponseBody = httpResponseBody;
}

public Map<String, String> getHttpResponseHeaders() {
return httpResponseHeaders;
}

public void setHttpResponseHeaders(Map<String, String> httpResponseHeaders) {
this.httpResponseHeaders = httpResponseHeaders;
}

public Metrics getMetrics() {
return metrics;
}

public void setMetrics(Metrics metrics) {
this.metrics = metrics;
}

public Boolean getHideHttpResponseHeaders() {
return hideHttpResponseHeaders;
}

public void setHideHttpResponseHeaders(Boolean hideHttpResponseHeaders) {
this.hideHttpResponseHeaders = hideHttpResponseHeaders;
}

public String getHttpContentType() {
return httpContentType;
}

public void setHttpContentType(String httpContentType) {
this.httpContentType = httpContentType;
}

}
Loading

0 comments on commit e26503f

Please sign in to comment.