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

amqplib-rpc-js

v0.1.5

Published

AMQPLib-RPC server and client for Node.JS

Downloads

10

Readme

RCP-Server and RCP-Client under amqplib for Node.JS

npm install amqplib-rpc-js

A library for organizing remote procedure calls based on the AMQP 0-9-1 protocol using the amqplib library.

Use on the server side


const Server = require('amqplib-rpc/Server');
//or
const Server = require('amqplib-rpc').Server;

const server = new Server({queue: "test"});

server.bind('method', (params, callback) => {
	//Do something
	callback(err, result);//Return result or error
});

//If you need verify params for correct, use schema json
server.bindSchema('method', {/*schema*/})

server.run()
	.then(function(res) {
		//Should return true
	})
	.catch(function(err) {
		//Return "Error" if server not started
	});

To stop the server, use the server.stop()

Use on the client side


const Client = require('amqplib-rpc/Client');
//or
const client = require('amqplib-rpc').Client;

const client = new Client({queue: "test"});

client.run()
	.then(function(res) {
		//"res" should return true
		client.call('method', params, function(err, resu) {
			//Do something with result
		});
	})
	.catch(function(err) {
		//Return "Error" if client not started
	});

To stop the client, use the client.stop()

Server options

  • hostname - Address for connection to MQServer (default: 'localhost')
  • port - Port for connection to MQServer (default: 5672)
  • username - Username for connection to MQServer (default: 'guest')
  • password - Password for connection to MQServer (default: 'guest')
  • heartbeat - Heartbeat for testing connection to MQServer (default: 30 secs)
  • queue - The name of the server queue. If the value is null, the name is generated automatically
  • prefetch - Determines how many maximum messages the server can receive from the queue (default: 3)
  • reconnect - Flag with server trying reconnection to MQ-server (default: false)
  • reconnectTimeout - Each Seconds server trying reconnect to MQ-server

Client options

  • hostname - Address for connection to MQServer (default: 'localhost')
  • port - Port for connection to MQServer (default: 5672)
  • username - Username for connection to MQServer (default: 'guest')
  • password - Password for connection to MQServer (default: 'guest')
  • heartbeat - Heartbeat for testing connection to MQServer (default: 30 secs)
  • queue - The name of the queue to which the client requests will be sent to the server. If the value is null, the name is generated automatically
  • timeout - The parameter is intended for setting the waiting for a response from the server. If the waiting time is longer than the set time, then there will be a generated TimeoutException error. The time is set in seconds. (default: 0 (infinity))

FAYULogger

Server and Client support logging with FAYULogger. You can create class FAUYLogger, create modules and transports, set into Server and/or Client:

const FAYULogger = require('fayulogger');
//Something for create Server and/or Client

let logger = new FAYULogger();
//Create and binding modules and transports
server.FAYULogger = logger;
client.FAYULogger = logger;

Warning

Module in develop.

Changelog

0.1.5

Add support reconnect for server and client

0.1.3

Added support json-schema for verify parameters

0.1.1

Change attribute "name" in error on "method" Change just error on class "RpcError"