Skip to content

An implementation of a leaky bucket control mechanism for Java

Notifications You must be signed in to change notification settings

linuslagerhjelm/LeakyBucket

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LeakyBucket

This is a simple implementation of a Leaky bucket data structure as it was described in the book Release it.

In short, a leaky bucket can be set to monitor an operation and keep track of how often the operation fails and throw an exception if the operation fails too many times within a specific time frame.

Basic usage:

var action = LeakyBucket.monitor(s -> System.out.println(s));
try {
    action.invoke("Hello!");
} catch (OperationFailedException e) {
    e.getTargetException().printStackTrace();
} catch (LeakyBucket.BucketOverflowException e) {
    // Do something in response to the failing operation
}

About

An implementation of a leaky bucket control mechanism for Java

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages