dubbo icon indicating copy to clipboard operation
dubbo copied to clipboard

Problem when trying script routing rules example in Chapter 6.33 of Dubbo user manual

Open myfly150 opened this issue 8 years ago • 2 comments

When I tried the script routing rules example , the return value of the example script was always the value of "invokers". The example script is as follow:

function route(invokers) {
    var result = new java.util.ArrayList(invokers.size());
    for (i = 0; i < invokers.size(); i ++) {
        if ("10.20.153.10".equals(invokers.get(i).getUrl().getHost())) {
            result.add(invokers.get(i));
        }
    }
    return result;
} (invokers); // Indicates that the method is executed immediately

According to the grammar of javascript, the meaning of the example script is :

function route(invokers) { ... } ;

(invokers)  // This is a single expression .The return value is always invokers.

instead of

function route(invokers) { ... } ;
route(invokers)

Actually, brackets surrounding the codeblock is simple solution.

(function route(invokers) { ... } (invokers) )

myfly150 avatar Apr 19 '18 02:04 myfly150

Hi, would you mind send a pull request? The documentation is hosted here: https://github.com/apache/incubator-dubbo-docs

ralf0131 avatar Apr 20 '18 01:04 ralf0131

@ralf0131 I have send a pull request #20 in incubator-dubbo-docs.

myfly150 avatar Apr 20 '18 02:04 myfly150