Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
node-dubbo-client
Advanced tools
npm install --save node-dubbo-client
consumer
const dubbo = require('node-dubbo-client');
dubbo.config({});
dubbo
.consumer
.getService({ service: 'test.service', group: 'test', version: '1.0.0' })
.call('testMethod', ['params'])
.then((result) => console.log(result))
.catch((err) => console.error(err));
provider
const dubbo = require('node-dubbo-client');
dubbo.config({});
dubbo
.provider
.init({ service: 'node.testService', group: 'node', version: '1.0.0' })
.addMethods({
test: (...args) => Promise.resolve({ result: 'hello world!' }),
})
.listen(3000);
初始化zookeeper连接.
订阅者模式下, service调用会一直阻塞到zookeeper连接创建.
发布者模式下, 本地http server启动后再连接到zookeeper, 并发布服务.
如果两个模式共用, 以发布者模式为准.
options
object
- 应用描述
string
- 当前应用名称string
- 当前应用的版本string
- dubbo版本number
- 进程Idobject
- service配置
number
(default: 45 * 1000) - 服务提供者调用超时时间boolean
(default: true) - 自动重试,服务提供者返回ECONNREFUSED,下线该提供者并重试object
string
(required)object
- node-zookeeper-client options
number
(default: 30 * 1000)number
(default: 1000)number
(default: 0)string
(default: 'round') - 订阅者调用的负载方式(round/random)boolean
(default: false) - 是否输出zookeeper推送的消息.订阅者模式下, 只关闭zookeeper连接.
发布者模式下,会依次进行以下操作:
日志输出, 如果给予回调函数, 默认使用debug 输出日志.
getService(serviceInfo:object):serviceObject
object
string
(required) 服务的namespacestring
(required)string
(required)serviceObject.call(methodName:string, data:Array<*>)
// 后端提供者
public String testMethod(int a, int b, int c);
// consumer 方法调用
const service = dubbo.consumer.getService({});
service
.call('testMethod',[1, 2, 3])
.then((str) => {})
.catch(() => {});
init(serviceInfo:object):Provider
provider基本信息声明.
Provider.addMethods(functions:object):Provider
批量添加provider方法
provider.addMethods({
method1: (a, b, c) => {
return 'something';
},
});
Provider.addMethod(name:string, handler:function(...params:*):*):Provider
添加单个provider方法
Provider.listen(port:number):Promise
启动provider的http服务器.该方法应该在provider配置完成之后调用
Provider.configServer(serverOpts:object):Provider
object
string
raw-body options.limit配置http服务, 目前只提供raw-body的配置项.
FAQs
node dubbo consumer/provider
The npm package node-dubbo-client receives a total of 9 weekly downloads. As such, node-dubbo-client popularity was classified as not popular.
We found that node-dubbo-client demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.