Class LimitEnforcer

java.lang.Object
com.xebialabs.xlrelease.limits.LimitEnforcer

@Service public class LimitEnforcer extends Object
Central utility for enforcing tenant limits across XL Release.
Since:
25.3.0
  • Constructor Details

    • LimitEnforcer

      public LimitEnforcer(com.xebialabs.xlrelease.repository.TenantLimitRepository tenantLimitRepository)
  • Method Details

    • enforceLimit

      public void enforceLimit(String tenantId, LimitEnforcer.LimitType limitType, int increment, IntSupplier currentCountSupplier)
      Enforces a specific limit by checking current count against configured limit.
      Parameters:
      tenantId - The tenant id for which limit should be checked
      limitType - The type of limit to validate
      increment - Number of items to be added
      currentCountSupplier - Supplier to get current count (lazy evaluation)
      Throws:
      com.xebialabs.xlrelease.exception.RateLimitReachedException - if the action would exceed the limit
    • enforceLimit

      public void enforceLimit(String tenantId, LimitEnforcer.LimitType limitType, int increment, IntSupplier currentCountSupplier, Optional<String> limitExceededMessage)
      Enforces a specific limit by checking current count against configured limit.
      Parameters:
      tenantId - The tenant id for which limit should be checked
      limitType - The type of limit to validate
      increment - Number of items to be added
      currentCountSupplier - Supplier to get current count (lazy evaluation)
      limitExceededMessage - The custom error message when limit exceeds
      Throws:
      com.xebialabs.xlrelease.exception.RateLimitReachedException - if the action would exceed the limit