Skip to content

Commit

Permalink
preparation for release
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimir-bukhtoyarov committed May 10, 2015
1 parent 7ef06f4 commit e36a0db
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 17 deletions.
16 changes: 10 additions & 6 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,16 @@ mvn clean install
The bucket4j library is distributed through [Bintray](http://bintray.com/), so you need to add Bintray repository to your `pom.xml`

```xml
<repositories>
<repository>
<id>jcenter</id>
<url>http://jcenter.bintray.com</url>
</repository>
</repositories>
<repositories>
<repository>
<id>bucket4j</id>
<snapshots>
<enabled>false</enabled>
</snapshots>
<name>bintray</name>
<url>http://dl.bintray.com/vladimir-bukhtoyarov/maven</url>
</repository>
</repositories>
```

Then include Bucket4j as dependency to your `pom.xml`
Expand Down
39 changes: 37 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
<url>http://github.com/vladimir-bukhtoyarov/bandwidth-limiter</url>
<connection>scm:git:git@github.com:vladimir-bukhtoyarov/bandwidth-limiter</connection>
<developerConnection>scm:git:git@github.com:vladimir-bukhtoyarov/bandwidth-limiter.git</developerConnection>
<tag>HEAD</tag>
</scm>

<developers>
Expand Down Expand Up @@ -215,12 +216,45 @@
</plugins>
</build>
</profile>
<profile>
<id>bintray</id>
<build>
<plugins>
<plugin>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<repositories>
<repository>
<id>jcenter</id>
<url>http://jcenter.bintray.com</url>
<id>bucket4j</id>
<snapshots>
<enabled>false</enabled>
</snapshots>
<name>bintray</name>
<url>http://dl.bintray.com/vladimir-bukhtoyarov/maven</url>
</repository>
</repositories>

Expand Down Expand Up @@ -279,4 +313,5 @@
<scope>test</scope>
</dependency>
</dependencies>

</project>
10 changes: 6 additions & 4 deletions src/main/java/com/github/bucket4j/Bucket.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public interface Bucket {
* Consumes as much tokens from bucket as available in the bucket in moment of invocation,
* but tokens which should be consumed is limited by than not more than {@code limit}.
*
* @param limit maximum nubmer of tokens to consume, should be positive.
*
* @return number of tokens which has been consumed, or zero if was consumed nothing.
*/
long consumeAsMuchAsPossible(long limit);
Expand All @@ -64,7 +66,7 @@ public interface Bucket {
* Consumes a single token from the bucket. If no token is currently available then this method will block until a
* token becomes available or current thread is interrupted. This is equivalent for {@code consume(1)}
*
* @throws InterruptedException
* @throws InterruptedException in case of current thread has been interrupted during waiting
*/
void consumeSingleToken() throws InterruptedException;

Expand All @@ -74,7 +76,7 @@ public interface Bucket {
*
* @param numTokens The number of tokens to consumeSingleToken from teh bucket, must be a positive number.
*
* @throws InterruptedException
* @throws InterruptedException in case of current thread has been interrupted during waiting
*/
void consume(long numTokens) throws InterruptedException;

Expand All @@ -88,7 +90,7 @@ public interface Bucket {
*
* @return true if token has been consumed or false when token has not been consumed
*
* @throws InterruptedException
* @throws InterruptedException in case of current thread has been interrupted during waiting
*/
boolean tryConsumeSingleToken(long maxWaitTime) throws InterruptedException;

Expand All @@ -101,7 +103,7 @@ public interface Bucket {
*
* @return true if {@code numTokens} has been consumed or false when {@code numTokens} has not been consumed
*
* @throws InterruptedException
* @throws InterruptedException in case of current thread has been interrupted during waiting
*/
boolean tryConsume(long numTokens, long maxWaitTime) throws InterruptedException;

Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/github/bucket4j/BucketBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public BucketBuilder(TimeMeter timeMeter) {
/**
* Constructs an instance of {@link com.github.bucket4j.local.LockFreeBucket}
*
* @see com.github.bucket4j.local.LockFreeBucket
* @return an instance of {@link com.github.bucket4j.local.LockFreeBucket}
*/
public Bucket build() {
BucketConfiguration configuration = createConfiguration();
Expand Down Expand Up @@ -198,7 +198,7 @@ public BucketBuilder withGuaranteedBandwidth(long maxCapacity, TimeUnit timeUnit
* In opposite to method {@link #withGuaranteedBandwidth(long, TimeUnit, long)},
* this method does not perform checking of limitation
* which disallow to have greater rate of guaranteed than rate of limited bandwidth,
* because rate is dynamic and depends from <code>bandwidthAdjuster<code/>.
* because rate is dynamic and depends from <code>bandwidthAdjuster</code>.
*
* @param bandwidthAdjuster provider of bandwidth capacity
* @param timeUnit Unit for period.
Expand All @@ -217,7 +217,7 @@ public BucketBuilder withGuaranteedBandwidth(BandwidthAdjuster bandwidthAdjuster
* Adds limited bandwidth for all buckets which will be constructed by this builder instance.
* <p>
* You can specify as many limited bandwidth as needed, but with following limitation: each limited bandwidth should has unique period,
* and when period of bandwidth <tt>X<tt/> is greater than bandwidth <tt>Y</tt>,
* and when period of bandwidth <tt>X</tt> is greater than bandwidth <tt>Y</tt>,
* then capacity of bandwidth <tt>X</tt> should be greater capacity of bandwidth <tt>Y</tt>,
* except cases when capacity of bandwidth <tt>X</tt> or <tt>Y</tt> is dynamic(provided by {@link com.github.bucket4j.BandwidthAdjuster}).
* <p>
Expand All @@ -241,7 +241,7 @@ public BucketBuilder withLimitedBandwidth(long maxCapacity, TimeUnit timeUnit, l
* Adds limited bandwidth for all buckets which will be constructed by this builder instance.
* <p>
* You can specify as many limited bandwidth as needed, but with following limitation: each limited bandwidth should has unique period,
* and when period of bandwidth <tt>X<tt/> is greater than bandwidth <tt>Y</tt>,
* and when period of bandwidth <tt>X</tt> is greater than bandwidth <tt>Y</tt>,
* then capacity of bandwidth <tt>X</tt> should be greater capacity of bandwidth <tt>Y</tt>,
* except cases when capacity of bandwidth <tt>X</tt> or <tt>Y</tt> is dynamic(provided by {@link com.github.bucket4j.BandwidthAdjuster}).
* <p>
Expand Down Expand Up @@ -269,7 +269,7 @@ public BucketBuilder withLimitedBandwidth(long maxCapacity, TimeUnit timeUnit, l
* Adds limited bandwidth for all buckets which will be constructed by this builder instance.
* <p>
* You can specify as many limited bandwidth as needed, but with following limitation: each limited bandwidth should has unique period,
* and when period of bandwidth <tt>X<tt/> is greater than bandwidth <tt>Y</tt>,
* and when period of bandwidth <tt>X</tt> is greater than bandwidth <tt>Y</tt>,
* then capacity of bandwidth <tt>X</tt> should be greater capacity of bandwidth <tt>Y</tt>,
* except cases when capacity of bandwidth <tt>X</tt> or <tt>Y</tt> is dynamic(provided by {@link com.github.bucket4j.BandwidthAdjuster}).
*
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/github/bucket4j/Buckets.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@ public final class Buckets {

/**
* Creates instance of {@link com.github.bucket4j.BucketBuilder} which will create buckets with {@link com.github.bucket4j.TimeMeter#SYSTEM_NANOTIME} as time meter.
*
* @return
*/
public static BucketBuilder withNanoTimePrecision() {
return new BucketBuilder(TimeMeter.SYSTEM_NANOTIME);
}

/**
* Creates instance of {@link com.github.bucket4j.BucketBuilder} which will create buckets with {@link com.github.bucket4j.TimeMeter#SYSTEM_MILLISECONDS} as time meter.
*
* @return
*/
public static BucketBuilder withMillisTimePrecision() {
return new BucketBuilder(TimeMeter.SYSTEM_MILLISECONDS);
Expand All @@ -40,6 +44,8 @@ public static BucketBuilder withMillisTimePrecision() {
* Creates instance of {@link com.github.bucket4j.BucketBuilder} which will create buckets with {@code customTimeMeter} as time meter.
*
* @param customTimeMeter object which will measure time.
*
* @return
*/
public static BucketBuilder withCustomTimePrecision(TimeMeter customTimeMeter) {
return new BucketBuilder(customTimeMeter);
Expand Down

0 comments on commit e36a0db

Please sign in to comment.