Skip to content

Very straight throttler implementation ( Java )

Notifications You must be signed in to change notification settings

bugsend/throttler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Throttler

This project helps its users to implement throttling functionality.

Right now it only supports sequential job's calling. Concurrent jobs exection is a subject for further work since it needs to create efficient job's termination logic.

So, the whole point of throttling is to perform some action not more than N times during some period of time T.

The following is a usage example:

Throttler t = new SequentialThrottler<>(13, 900, () -> {
        try {

            Thread.sleep(Math.abs(ThreadLocalRandom.current().nextLong(12, 98)));

        } catch (InterruptedException e) {

            e.printStackTrace();

        }

        System.err.print(" J. ");

    });

    t.doJob();

Here:

  1. 13 - is how many times job is about to execute
  2. 900 - time range in milliseconds for job to being executed.

That's it.

About

Very straight throttler implementation ( Java )

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages