npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-zookeeper-dubbo-plus

v3.0.16

Published

node connect dubbo by default protocol in zookeeper

Downloads

8

Readme

node-zookeeper-dubbo-plus

node-zookeeper-dubbo年久失修,无法支持dubbo 2.6.3+协议,错误如下:

Unknown result flag, expect '0' '1' '2', get 3
Unknown result flag, expect '0' '1' '2', get 4
Unknown result flag, expect '0' '1' '2', get 5

修改内容

  • 增加对dubbo 2.6.3+协议的支持,方法比较粗暴,直接忽略了attachments信息。
  • 消除DEP0005警告,替换Buffer() => Buffer.from()

其他使用方法同原包,变更包名即可。以下为原文:

node-zookeeper-dubbo

nodejs通过dubbo默认协议通信

3.0版本发布,使用长连接进行通信,同时重构了大量代码,性能几乎翻倍。

用法

const nzd=require('node-zookeeper-dubbo');
const app=require('express')();
const opt={
  application:{name:'fxxk'},
  registry:'www.cctv.com:2181',
  dubboVer:'2.5.3.6',
  root:'dubbo',
  dependencies:{
    Foo:{
      interface:'com.service.Foo',
      version:'LATEST',
      timeout:6000,
      group:'isis',
      methodSignature: { // optional
        findById : (id) => [ {'$class': 'java.lang.Long', '$': id} ],
        findByName : (name) => [ java.String(name) ],
      }
    },
    Bar:{
      interface:'com.service.Bar',
      version:'LATEST',
      timeout:6000,
      group:'gcd'
    }
  }
}

const Dubbo=new nzd(opt);

Dubbo.on("service:changed", (event)=>console.log(event))

const customerObj = {
  $class: 'com.xxx.XXXDTO',
  $: {
    a: 1,
    b: 'test',
    c: {$class: 'java.lang.Long', $: 123}
  }
};

app.get('/foo',(req,res)=>{
  Dubbo.Foo
    .xxMethod({'$class': 'java.lang.Long', '$': '10000000'},customerObj)
    .then(data=>res.send(data))
    .catch(err=>res.send(err))
})

app.get('/foo/findById',(req,res)=>{
  Dubbo.Foo
    .findById(10000)
    .then(data=>res.send(data))
    .catch(err=>res.send(err))
})

app.listen(9090)

注意

须等待初始化完毕才能正常使用,标志:Dubbo service init done

参数配置说明

  • application
    • name - 项目名称,必填
  • registry - zookeeper服务地址,必填
  • dubboVer - dubbo版本,必填
  • root - 注册到zookeeper上的根节点名称
  • dependencies - 依赖的服务集,必填
    • Foo - 自定义名称,这里方便起见用Foo作为示例,必填
      • interface - 服务地址,必填
      • version - 注册的服务版本
      • timeout - 超时时间,默认6000
      • group - 分组
      • methodSignature - 方法签名

可以选择使用 js-to-java, 能极大提高效率。

const java = require('js-to-java');
const arg = {$class:'int',$:123};
//等同于
const arg = java('int',123);

感谢为这个项目作出过贡献的每个人,感谢为我提供思路和指导的 @caomu,感谢 js-to-java, hessian.js 的作者们。