dubbo-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smallh0a1n1d0s (GitHub) <git...@apache.org>
Subject [GitHub] [incubator-dubbo] smallh0a1n1d0s commented on issue #1861: the issue for setting loadbalancer.select (@SPI) completely extendable
Date Thu, 14 Mar 2019 10:24:09 GMT
@zonghaishang 

@version 2.7.0
 ```java
    private Optional<List<Router>> toRouters(List<URL> urls) {
        if (urls == null || urls.isEmpty()) {
            return Optional.empty();
        }

        List<Router> routers = new ArrayList<>();
        for (URL url : urls) {
            if (Constants.EMPTY_PROTOCOL.equals(url.getProtocol())) {
                continue;
            }
            String routerType = url.getParameter(Constants.ROUTER_KEY);
            if (routerType != null && routerType.length() > 0) {
                url = url.setProtocol(routerType);
            }
            try {
 ######### Router looks like a single extension rather than The Filter Design Pattern############
                Router router = routerFactory.getRouter(url);
                if (!routers.contains(router)) {
                    routers.add(router);
                }
            } catch (Throwable t) {
                logger.error("convert router url to router error, url: " + url, t);
            }
        }

        return Optional.of(routers);
    }
```

[ Full content available at: https://github.com/apache/incubator-dubbo/issues/1861 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org


Mime
View raw message