divide
Pluginhttp protocol
requests.shenyu-plugin-divide
.org.apache.shenyu.plugin.divide.DividePlugin
.pom.xml
file.<dependency> <groupId>org.apache.shenyu</groupId> <artifactId>shenyu-spring-boot-starter-gateway</artifactId> <version>${project.version}</version> </dependency>
shenyu-admin
--> BasicConfig --> Plugin --> divide
set Status enable.shenyu: register: registerType: http serverLists: http://localhost:9095 props: username: admin password: 123456 client: http: # http protocol props: contextPath: /http # routing address for each service
The following example uses the http access method. Currently, the client supports the following access methods: http, zookeeper, etcd, nacos, consul. For detailed access configuration parameters, please refer to Client Access Configuration.
Only http-type registries support upstream detection.
shenyu: register: registerType: http # Only http-type register center support upstream detection. serverLists: props: checked: true # The default is true, set to false, do not detect. zombieCheckTimes: 5 # The maximum number of zombie upstream detections. If it exceeds 5 times, its validity will no longer be detected. The default value is 5. scheduledTime: 10 # Timing detection interval, the default is 10 seconds. zombieRemovalTimes: 60 # How many seconds the upstream is offline to be considered as a zombie upstream, the default is 60 seconds.
After the client is started, the selector and rule information will be automatically registered in shenyu-admin -> Plugin List -> Proxy -> Divide.
Example of divide selector. For general selector configuration, please refer to Selectors and Rules.
host
: fill in localhost
, this field is not used currently.ip:port
: ip
and port, fill in the ip
+ port of your real service here.protocol
: http
protocol, fill in http:
or https:
, if not fill in, the default is: http:
.startupTime
: Startup time in milliseconds.weight
: load balancing weight, the default value of service startup automatic registration is 50.warmupTime
: Warmup time, in milliseconds. The server during warmup will calculate the instantaneous weight, and the calculated value will be smaller than the actual configured weight to protect the server just started. The default value of service startup registration is 10. For example, the warm-up time is 100 milliseconds, the current startup is 50 milliseconds, the configured weight is 50, and the actual weight is 25.status
: On or off, this selector is valid only in the on state.Example of divide rule. For general rule configuration, please refer to selectors and rules.
loadStrategy
: If the http
client is a cluster, which load balancing strategy is used when the Apache ShenYu
gateway is called, currently supports roundRobin
, random
and hash
.timeout
: The timeout for calling the http
client.retry Count
: The number of retries that failed to call the http
client timeout.headerMaxSize
: The maximum value of the requested header
.requestMaxSize
: The maximum value of the request body.retryStrategy
: Supported since 2.4.3
, retry strategy after failure, default current
to maintain compatibility with lower versions. For example, there are 3 downstream services http:localhost:1111
, http:localhost:1112
and http:localhost:1113
, assuming the first load balancing to http:localhost:1111
and call failed
. Using the current
strategy will continue to retry calling http:localhost:1111
; using the failover
strategy will retry calling other services such as http:localhost:1112
through the load balancing
, if it fails again at this time , call to http:localhost:1113
until no service is available.To be added, welcome contribute.
To be added, welcome contribute.
shenyu-admin
--> BasicConfig --> Plugin --> divide
set Status disable.