Giter Site home page Giter Site logo

node-zookeeper-dubbo's Introduction

node-zookeeper-dubbo

nodejs connect dubbo by default protocol in zookeeper

NPM version Downloads

There are a lot of improvements in v2.0

if you want coexistence between different versions,use niv.

config

env

dubbo service version

conn

zookeeper conn url

path

the service you need

version

dubbo version

services

Usage

first you need to init the service so that invoke the consumers in zk

app.js

var service=require('node-zookeeper-dubbo');
new Service({
  env:'test',
  conn:'127.0.0.1:2180',
  services: require('./dubbo/services')
})

/dubbo/services.js

'use strict';

module.exports = {
  Foo: 'com.customer.FooService',
  Bar: 'com.customer.BarService'
};

in you business code, service.js

var Service=require('node-zookeeper-dubbo');

var opt={
  env:'test', // dubbo service version
  gruop:'dubbo', // dubbo group default by '',optional
  conn:'127.0.0.1:2180', // zookeeper url
  path:'com.customer.Service', // service url
  version:'2.3.4.5' // dubbo version
}

var method="getUserByID";
var arg1={$class:'int',$:123}
var args=[arg1];

var service = new Service(opt);
service.excute(method,args,function(err,data){
  if(err){
    console.log(err);
    return;
  }
  console.log(data)
})

or

service
  .excute(method,args)
  .then(function(data){
    console.log(data);
  })
  .catch(function(err) {
    console.log(err);
  })
  
or

service.init().then(function() {
	//更优雅地通过.的方式调用远程方法
	service.checkLogin(arg1, arg2)
	  .then(function(data){
	    console.log(data);
	  })
	  .catch(function(err) {
	    console.log(err);
	  });
});

you can use js-to-java

var arg1={$class:'int',$:123};
//equivalent
var arg1=java('int',123);

Close zookeeper connection

Default the zookeeper connection is keep-alive,you can call service.zoo.close() to close the connect;

Optimize

There are a lot of non-functional requirements need to be satisfied, but time is hard, so pls patience, we'll scare you.

Contributors

PanEW

zhanghua

caomu

zhchj126

node-zookeeper-dubbo's People

Contributors

omnip620 avatar caomu avatar lifubang avatar lianer avatar

Watchers

James Cloos 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.