Skip to content

dwd-fe/node-zookeeper-dubbo

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 'dubbo',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);
  })
});

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

About

nodejs connect dubbo by default protocol in zookeeper

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%