How to use the pm2-axon-rpc.Server function in pm2-axon-rpc

To help you get started, we’ve selected a few pm2-axon-rpc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github LiskHQ / lisk-sdk / framework / src / controller / channels / child_process_channel.js View on Github external
this.busRpcClient = new RPCClient(this.busRpcSocket);
		this.busRpcClientCallPromisified = util.promisify(this.busRpcClient.call);

		// Channel Publish Socket is only required if the module has events
		if (this.eventsList.length > 0) {
			this.pubSocket = axon.socket('pub-emitter');
			this.pubSocket.connect(socketsPath.sub);
		}

		// Channel RPC Server is only required if the module has actions
		if (this.actionsList.length > 0) {
			this.rpcSocketPath = `unix://${socketsPath.root}/${this.moduleAlias}_rpc.sock`;

			this.rpcSocket = axon.socket('rep');
			this.rpcSocket.bind(this.rpcSocketPath);
			this.rpcServer = new RPCServer(this.rpcSocket);

			this.rpcServer.expose('invoke', (action, cb) => {
				this.invoke(action)
					.then(data => cb(null, data))
					.catch(error => cb(error));
			});

			this.rpcServer.expose('invokePublic', (action, cb) => {
				this.invokePublic(action)
					.then(data => cb(null, data))
					.catch(error => cb(error));
			});
		}

		return this.setupSockets();
	}
github DiffBit / CryptoTradePlatform / node_modules / pm2 / lib / Interactor / Daemon.js View on Github external
activateRPC : function() {
    console.log('Launching Interactor exposure');

    var self          = this;
    var rep           = axon.socket('rep');
    var daemon_server = new rpc.Server(rep);
    var sock          = rep.bind(cst.INTERACTOR_RPC_PORT);

    daemon_server.expose({
      kill : function(cb) {
        console.log('Killing interactor');
        cb(null);
        return Daemon.exit();
      },
      passwordSet : function(cb) {
        global._pm2_password_protected = true;
        return cb(null);
      },
      getInfos : function(cb) {
        if (self.opts &&
            self.opts.DAEMON_ACTIVE == true)
          return cb(null, {
github LiskHQ / lisk-sdk / framework / src / controller / bus.js View on Github external
async setup() {
		if (!this.config.ipc.enabled) {
			return true;
		}

		this.pubSocket = axon.socket('pub-emitter');
		this.pubSocket.bind(this.config.socketsPath.pub);

		this.subSocket = axon.socket('sub-emitter');
		this.subSocket.bind(this.config.socketsPath.sub);

		this.rpcSocket = axon.socket('rep');
		this.rpcServer = new RPCServer(this.rpcSocket);
		this.rpcSocket.bind(this.config.socketsPath.rpc);

		this.rpcServer.expose(
			'registerChannel',
			(moduleAlias, events, actions, options, cb) => {
				this.registerChannel(moduleAlias, events, actions, options)
					.then(() => cb(null))
					.catch(error => cb(error));
			},
		);

		this.rpcServer.expose('invoke', (action, cb) => {
			this.invoke(action)
				.then(data => cb(null, data))
				.catch(error => cb(error));
		});
github jitta / spinal / lib / node.js View on Github external
var Spinal = function(url, options){
  var that = this
  if (typeof options == 'undefined') options = {}

  var rep = axon.socket('rep')
  var req = axon.socket('req')
  this.id = puid.generate()
  this.server = new rpc.Server(rep)
  this.client = new rpc.Client(req)
  this.jobHandler = {}
  this.broker_url = process.env.SPINAL_BROKER || url
  this.hostname = process.env.SPINAL_HOST || options.hostname
  this.port = parseInt(process.env.SPINAL_PORT || options.port)
  this.namespace = options.namespace
  this.timeout = {}
  this.initialized = false
  this.connected = false
  this._broker_data = {
    version: null,
    methods: []
  }
  this.config = {}
  this.nock = new Nock(this)
  if (options.heartbeat_interval) HEARTBEAT_INTERVAL = parseInt(options.heartbeat_interval)
github jitta / spinal / lib / broker.js View on Github external
var Broker = function(options){
  var that = this
  this.id = puid.generate()
  this.rep = new axon.RepSocket
  this.server = new rpc.Server(this.rep)
  this.options = options || {}
  this.redis = null
  this.redis_prefix = this.options.redis_prefix || 'spinal:'
  this.queue = null
  if(this.options.redis){
    this.redis = new Redis(this.options.redis)
    debug('[redis] initialize')
    var Queue = require('./queue')
    this.queue = new Queue(this, {redis: this.options.redis})
  }
  this.router = new Router(this, {
    redis: this.redis,
    redis_prefix: this.redis_prefix || 'spinal:'
  })
  this.metrics = (require('./metrics'))(this, this.options)
  if(this.options.restapi){

pm2-axon-rpc

Remote procedure calls built on top of axon.

MIT
Latest version published 4 years ago

Package Health Score

65 / 100
Full package analysis

Popular pm2-axon-rpc functions