接口 Router
-
- 所有超级接口:
Comparable<Router>
- 所有已知实现类:
AbstractRouter,AppRouter,ConditionRouter,ListenableRouter,MeshRuleRouter,MockInvokersSelector,ScriptRouter,ServiceRouter,TagRouter
public interface Router extends Comparable<Router>
Router. (SPI, Prototype, ThreadSafe)
-
-
字段概要
字段 修饰符和类型 字段 说明 static intDEFAULT_PRIORITY
-
方法概要
所有方法 实例方法 抽象方法 默认方法 修饰符和类型 方法 说明 default intcompareTo(Router o)intgetPriority()Router's priority, used to sort routers.org.apache.dubbo.common.URLgetUrl()Get the router url.booleanisForce()To decide whether this router should take effect when none of the invoker can match the router rule, which means theroute(List, URL, Invocation)would be empty.booleanisRuntime()To decide whether this router need to execute every time an RPC comes or should only execute when addresses or rule change.default <T> voidnotify(List<Invoker<T>> invokers)Notify the router the invoker list.<T> List<Invoker<T>>route(List<Invoker<T>> invokers, org.apache.dubbo.common.URL url, Invocation invocation)Filter invokers with current routing rule and only return the invokers that comply with the rule.default voidstop()
-
-
-
字段详细资料
-
DEFAULT_PRIORITY
static final int DEFAULT_PRIORITY
- 另请参阅:
- 常量字段值
-
-
方法详细资料
-
getUrl
org.apache.dubbo.common.URL getUrl()
Get the router url.- 返回:
- url
-
route
<T> List<Invoker<T>> route(List<Invoker<T>> invokers, org.apache.dubbo.common.URL url, Invocation invocation) throws RpcException
Filter invokers with current routing rule and only return the invokers that comply with the rule.- 参数:
invokers- invoker listurl- refer urlinvocation- invocation- 返回:
- routed invokers
- 抛出:
RpcException
-
notify
default <T> void notify(List<Invoker<T>> invokers)
Notify the router the invoker list. Invoker list may change from time to time. This method gives the router a chance to prepare beforeroute(List, URL, Invocation)gets called.- 类型参数:
T- invoker's type- 参数:
invokers- invoker list
-
isRuntime
boolean isRuntime()
To decide whether this router need to execute every time an RPC comes or should only execute when addresses or rule change.- 返回:
- true if the router need to execute every time.
-
isForce
boolean isForce()
To decide whether this router should take effect when none of the invoker can match the router rule, which means theroute(List, URL, Invocation)would be empty. Most of time, most router implementation would default this value to false.- 返回:
- true to execute if none of invokers matches the current router
-
getPriority
int getPriority()
Router's priority, used to sort routers.- 返回:
- router's priority
-
stop
default void stop()
-
compareTo
default int compareTo(Router o)
- 指定者:
compareTo在接口中Comparable<Router>
-
-