SDK reference overview

更新时间:
复制 MD 格式

After you connect an application to AHAS Application Protection using the SDK, you can use the SDK to configure throttling for code blocks, define application behavior when throttling or degradation occurs, and set up extension interfaces if the default configurations do not meet your needs.

Configure throttling for code blocks

AHAS works with resources. To throttle a code block, you must first define it as a resource. After you define the resource, you can configure a corresponding rule in the AHAS console. The rule takes effect after it is configured. You can define resources in the following ways:

  • Define a resource using an annotation
  • Define a resource by throwing an exception
  • Define a resource by returning a Boolean value
  • Support for asynchronous invocations
  • Default adapters for mainstream frameworks

For more information about defining resources, see Define resources.

Configure the logic after a rule is triggered

When an application triggers a throttling, degradation, or system rule, a child class of the BlockException exception is thrown by default. For example, if a throttling rule is triggered, a FlowException is thrown. If a degradation rule is triggered, a DegradeException is thrown.

If the default configurations do not meet your needs, you can configure the logic for when an application triggers a throttling or degradation rule in the following ways.

  • Annotation: This method is suitable for connection types such as Spring Boot applications with custom instrumentation, custom instrumentation, and annotation-based connections.
  • Web Servlet Filter: This method is suitable for connection types such as Spring Boot applications with HTTP instrumentation and web application connections.
  • Dubbo Adapter: This method is suitable for the Dubbo application connection type.

For more information, see Configure the logic after a rule is triggered.

Common classes, methods, and extension interfaces

AHAS Application Protection provides common classes, their extension methods, and extension interfaces. For more information, see Common classes and their methods and Extension interfaces.

More information

  • AHAS provides a sample project to help you try out the application protection feature. For more information, see Sample project.
  • You can view logs to quickly check the running status of a single machine and troubleshoot issues. For more information about logs, see Important logs.