Apache ShenYu Documentation

website·Indexed 20 days ago

https://shenyu.apache.org/

Documentation for Apache ShenYu, a dynamic gateway. It includes user guides for proxy configuration (Dubbo, HTTP), admin usage of selectors and rules, and a plugin center covering security (OAuth2, Sign, CryptorRequest), observability (Logging-Console, ElasticSearch, AliyunSls), and fault tolerance (Resilience4j). Also provides client integration guides for Golang and .NET Core with support for registration centers like Nacos, Etcd, Consul, and Zookeeper.

Tokens
1.3M
Snippets
5.2K
Records
8.9K
Agent score
90%

What's inside Apache ShenYu

  1. Overview of ShenYu Data Synchronization

    ShenYu Gateway uses a data synchronization strategy to ensure that configuration changes made in the shenyu-admin background are immediately reflected in the gateway's local memory cache. This architecture ensures high availability and fast request processing by avoiding database queries for every request. Supported data types for synchronization include plugin selectors, rules, metadata, and signature data. All configurations take effect immediately without requiring a service restart.
  2. Overview of the aiPrompt plugin

    The aiPrompt plugin is used to dynamically inject preset prompt content, such as system-role messages or contextual information, into requests before they are forwarded to an LLM. It typically inserts specified prompt text into the request body (e.g., adding a 'system' message at the beginning of a message list) to ensure unified context control or preset roles across requests. It is designed to be used in conjunction with the aiProxy plugin.
  3. Overview of ParamMapping Plugin

    The paramMapping plugin is used to edit request parameters by adding, removing, or replacing fixed parameters in the request body. It has been available since ShenYu version 2.4.0. The core logic is implemented in the shenyu-plugin-param-mapping module via the org.apache.shenyu.plugin.param.mapping.ParamMappingPlugin class.
  4. Overview of the Apache ShenYu Request Plugin

    The Request Plugin allows users to make customized changes to request parameters, request headers, and Cookies when proxying a target service. It is used to add, modify, or remove these elements based on defined selectors and rules. This plugin has been available since ShenYu version 2.4.0.
  5. Overview of the aiProxy plugin

    The aiProxy plugin serves as a forwarding proxy for Large Language Model (LLM) requests. It allows users to send requests to ShenYu, which then forwards them to a configured LLM provider (e.g., OpenAI, Alibaba Cloud, or local models compatible with OpenAI protocols) using settings like provider name, model name, and API keys. In this architecture, the LLM provider acts as the upstream application service.
  6. Overview of Apache ShenYu Sign Plugin

    The Sign Plugin (available since ShenYu 2.4.0) provides signature authentication for requests passing through the Apache ShenYu gateway. It supports authorization based on HTTP headers alone, or a combination of HTTP headers and the request body. The core implementation is located in the shenyu-plugin-sign module, specifically the org.apache.shenyu.plugin.sign.SignPlugin class.
  7. Overview of the ShenYu Mock Plugin

    The Mock Plugin allows developers to facilitate testing by specifying custom HTTP status codes and response bodies for requests. It supports dynamic data generation using ${} placeholders and SpEL expressions.

    Security Warning: The plugin supports SpEL expressions for flexible data generation. Because SpEL expressions can execute malicious scripts or destructive programs, it is recommended to use them only in safe environments (e.g., intranets) and follow security best practices.

  8. Overview of the Logging-Console Plugin

    The Logging-Console Plugin (available since ShenYu 2.4.0) is used for debugging during development or troubleshooting online. It collects HTTP request URLs, headers, request bodies, responses, and response bodies using logback or log4j, saving the log files locally.

    • Core Module: shenyu-pluign-logging-console
    • Core Class: org.apache.shenyu.plugin.logging.console.LoggingConsolePlugin
  9. Overview of the ContextPath Plugin

    The ContextPath Plugin allows different services to perform traffic governance by setting unique context paths. Its primary functionality is to set the context path for a service and uniformly prefix the interface address of the service when the interface is called. It was introduced in ShenYu version 2.3.0.
  10. Overview of the ShenYu Rewrite Plugin

    The Rewrite Plugin is used to rewrite the request URI when the request URI needs to be different from the target service path. It has been available since ShenYu version 2.4.0.

    Technical Details:

    • Core Module: shenyu-plugin-rewrite
    • Core Class: org.apache.shenyu.plugin.rewrite.RewritePlugin
  11. Overview of the ShenYu Divide Plugin

    The divide plugin is used for handling HTTP protocol requests in Apache ShenYu. It provides capabilities for traffic management (such as A/B testing and grayscale testing), service load balancing, and request timeout management.

    Key functionalities include:

    • Traffic management based on URI, headers, and queries.
    • Load balancing strategies: IP Hash (consistent hash with virtual nodes), Round-Robin (weighted polling), and Random (weighted random).
    • Service warm-up support to protect newly started servers.
    • Request constraints: Maximum request header size, maximum request body size, and request-level timeouts.
    • Retry policies: current (retry the same failed server) and failover (retry other available servers).