Annotation Interface Rale4j


@Target(METHOD) @Retention(RUNTIME) public @interface Rale4j
Custom annotation to enforce rate limiting on methods.

Example usage:

 @Rale4j(strategy = "guava", limit = 10, duration = 60)
 public String myMethod() {
     return "Rate-limited method";
 }
 
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    int
    The time window (in seconds) for the rate limit.
    int
    The maximum number of requests allowed within the duration.
    The rate-limiting strategy to use (e.g., "guava", "redis").
  • Element Details

    • strategy

      String strategy
      The rate-limiting strategy to use (e.g., "guava", "redis").
      Returns:
      the strategy name
      Default:
      "guava"
    • limit

      int limit
      The maximum number of requests allowed within the duration.
      Returns:
      the request limit
      Default:
      10
    • duration

      int duration
      The time window (in seconds) for the rate limit.
      Returns:
      the duration in seconds
      Default:
      60