TokenBucketGroup

com.digitaltangible.tokenbucket.TokenBucketGroup
class TokenBucketGroup(val size: Long, val rate: Double, clock: Clock) extends Serializable

TokenBucketGroup which synchronizes the bucket token requests. Token Bucket implementation as described here http://en.wikipedia.org/wiki/Token_bucket

Value parameters

clock

for mocking the current time.

rate

refill rate in tokens per second

size

bucket size

Attributes

Graph
Supertypes
trait Serializable
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def consume(key: Any, required: Int): Long

First refills all buckets at the given rate, then tries to consume the required amount. If no bucket exists for the given key, a new full one is created.

First refills all buckets at the given rate, then tries to consume the required amount. If no bucket exists for the given key, a new full one is created.

Value parameters

required

number of tokens to consume

Attributes

Concrete fields

val rate: Double
val size: Long