Class ConditionStateRouter<T>
java.lang.Object
org.apache.dubbo.rpc.cluster.router.state.AbstractStateRouter<T>
org.apache.dubbo.rpc.cluster.router.condition.ConditionStateRouter<T>
- All Implemented Interfaces:
StateRouter<T>
Condition Router directs traffics matching the 'when condition' to a particular address subset determined by the 'then condition'.
One typical condition rule is like below, with
1. the 'when condition' on the left side of '=>' contains matching rule like 'method=sayHello' and 'method=sayHi'
2. the 'then condition' on the right side of '=>' contains matching rule like 'region=hangzhou' and 'address=*:20881'
By default, condition router support matching rules like 'foo=bar', 'foo=bar*', 'arguments[0]=bar', 'attachments[foo]=bar', 'attachments[foo]=1~100', etc.
It's also very easy to add customized matching rules by extending ConditionMatcherFactory
and ValuePattern
--- scope: service force: true runtime: true enabled: true key: org.apache.dubbo.samples.governance.api.DemoService conditions: - method=sayHello => region=hangzhou - method=sayHi => address=*:20881 ...
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConditionStateRouter(org.apache.dubbo.common.URL url) ConditionStateRouter(org.apache.dubbo.common.URL url, String rule, boolean force, boolean enabled) -
Method Summary
Methods inherited from class org.apache.dubbo.rpc.cluster.router.state.AbstractStateRouter
buildSnapshot, getNextRouter, getRuleRepository, getUrl, isForce, notify, route, setForce, setNextRouter, setUrlMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.dubbo.rpc.cluster.router.state.StateRouter
stop
-
Field Details
-
NAME
- See Also:
-
-
Constructor Details
-
ConditionStateRouter
public ConditionStateRouter(org.apache.dubbo.common.URL url, String rule, boolean force, boolean enabled) -
ConditionStateRouter
public ConditionStateRouter(org.apache.dubbo.common.URL url)
-
-
Method Details
-
init
-
isRuntime
public boolean isRuntime()Description copied from interface:StateRouterTo decide whether this router need to execute every time an RPC comes or should only execute when addresses or rule change.- Specified by:
isRuntimein interfaceStateRouter<T>- Overrides:
isRuntimein classAbstractStateRouter<T>- Returns:
- true if the router need to execute every time.
-