Module bus.limiter

Class Registry

java.lang.Object
org.miaixz.bus.limiter.Registry

public class Registry extends Object
Manages the registration of various limiting and protection rules, such as downgrade, hotspot, and request limiting. This class interacts with Sentinel's FlowRuleManager to configure flow control rules dynamically.
Since:
Java 17+
Author:
Kimi Liu
  • Constructor Details

    • Registry

      public Registry()
  • Method Details

    • register

      public static void register(Downgrade downgrade, String resourceKey)
      Registers a downgrade rule based on the provided Downgrade annotation. If a flow rule for the given resource key does not already exist, a new FlowRule is created with the specified grade and count, and then loaded into Sentinel's FlowRuleManager.
      Parameters:
      downgrade - The Downgrade annotation containing the downgrade configuration.
      resourceKey - The unique identifier for the resource to which the downgrade rule applies.
    • register

      public static void register(Hotspot hotspot, String resourceKey)
      Registers a hotspot rule based on the provided Hotspot annotation. If a flow rule for the given resource key does not already exist, a new FlowRule is created with the specified grade and count. Note that Sentinel versions like 1.8.8 might not fully support hotspot parameter flow control directly, and it might be simplified to a regular flow control rule.
      Parameters:
      hotspot - The Hotspot annotation containing the hotspot configuration.
      resourceKey - The unique identifier for the resource to which the hotspot rule applies.
    • register

      public static void register(Limiting limiting, String resourceKey)
      Registers a request limiting rule based on the provided Limiting annotation. If a flow rule for the given resource key does not already exist, a new FlowRule is created with a default QPS grade and the specified count, then loaded into Sentinel's FlowRuleManager.
      Parameters:
      limiting - The Limiting annotation containing the limiting configuration.
      resourceKey - The unique identifier for the resource to which the limiting rule applies.