Git Product home page Git Product logo

dubbo-node-client's Introduction

如何安装

Node.js.

NPM

npm install dubbo-node-client

注意

该项目只支持 jsonrpc协议, 不支持 dubbo协议的服务提供者


如何使用

服务提供者

public interface PhoneNoCheckProvider {

    boolean isPhoneNoLimit(Operators operators, String no, String userid);

    boolean isPhone(String no);
}

消费者

//
var dubboClient = require('dubbo-node-client');

//加载配置文件
dubboClient.config(require('./dubbo.config.js'));

//获取serivce
var phoneNoCheckService = dubboClient.getService('com.ofpay.ofdc.api.phone.PhoneNoCheckProvider', version, group);

//调用方式一, 这种可以立即调用, 无需延迟
phoneNoCheckService.call('isPhone', "13999999999")
    .then(function(result){ //成功
        return this.call('isPhoneNoLimit', "MOBILE", "130000", "A001");
    })
    .catch(function(error){ //失败
    })
    .finally(function(){ //不管成功还是失败
    });

//调用方式二, 这种需要延迟, 因为provider的方法是由zookeeper的节点提供,
//所以要先查到这个provider的节点, 这个步骤是异步的, 就导致你如果直接调用方法会报错
phoneNoCheckService.isPhone('xxxxx');

//当然如果你是在Express里面调用, 那肯定没有问题.
function doFoo(req, res){
    phoneNoCheckService.isPhone('xxxxx')
            .then(function(out){
                res.send(out);
            });
}

dubbo-node-client's People

Contributors

binlaniua avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.