Skip to content

wbenxin/amqplib-rpc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

amqplib-rpc

基于amqplib实现的RPC服务. 具有以下特点:

  • 基于replyTocorrelationId机制
  • 服务端断线自动重连
  • 客户端调用支持超时
  • RabbitMQ

安装

npm i @wbenxin/amqplib-rpc

使用

Server

const {Server} = require('@wbenxin/amqplib-rpc');

const server = new Server(config);
server.on('calc', async (a, b)=>{
  return a+b;
});

config的内容如下:

{
  url: 'string'
}

Client

const {Client} = require('@wbenxin/amqplib-rpc');

const client = new Client(config);
client.call('calc', [1,2]).then(sum => {
  console.log(sum);
}).catch(e => {
  console.error(e);
});

config的内容如下:

{
  url: 'string',
  timeout: int,   // 可选. 默认30秒
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published