Tabnine Logo
RateLimit.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
sirius.kernel.commons.RateLimit
constructor

Best Java code snippets using sirius.kernel.commons.RateLimit.<init> (Showing top 2 results out of 315)

origin: com.scireum/sirius-kernel

/**
 * Creates a new call based rate limit.
 * <p>
 * Calling {@link #check()} on will only return <tt>true</tt> every n-th call and <tt>false</tt> otherwise.
 *
 * @param n the number of calls to skip (returning <tt>false</tt>) by {@link #check()} before <tt>true</tt>
 *          is returned
 * @return a new call based rate limit
 */
public static RateLimit everyNthCall(long n) {
  return new RateLimit(n, 0, Mode.CALL_BASED);
}
origin: com.scireum/sirius-kernel

/**
 * Creates a new time based rate limit which permits up to N calls per interval.
 * <p>
 * Calling {@link #check()} on will only return <tt>true</tt> N times in every given interval,
 * <tt>false</tt> otherwise.
 *
 * @param interval           the amount of time after a call to {@link #check()} returns <tt>true</tt> again
 * @param unit               the unit for amount
 * @param permitsPerInterval the number of times to return <tt>true</tt> per interval
 * @return a new time based rate limit
 */
public static RateLimit nTimesPerInterval(long interval, TimeUnit unit, int permitsPerInterval) {
  return new RateLimit(TimeUnit.MILLISECONDS.convert(interval, unit), permitsPerInterval, Mode.TIME_BASED);
}
sirius.kernel.commonsRateLimit<init>

Popular methods of RateLimit

  • check
    Checks whether the rate limit constraints permit another call or not.
  • timeInterval
    Creates a new time based rate limit. Calling #check() on will only return true every after the given
  • nTimesPerInterval
    Creates a new time based rate limit which permits up to N calls per interval. Calling #check() on w

Popular in Java

  • Updating database using SQL prepared statement
  • getSupportFragmentManager (FragmentActivity)
  • getContentResolver (Context)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • FileNotFoundException (java.io)
    Thrown when a file specified by a program cannot be found.
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • LinkedHashMap (java.util)
    LinkedHashMap is an implementation of Map that guarantees iteration order. All optional operations a
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • JButton (javax.swing)
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now