New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

hydra-plugin-rpc

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hydra-plugin-rpc

simple distributed RPC using Hydra

latest
Source
npmnpm
Version
0.0.4
Version published
Maintainers
1
Created
Source

Hydra-plugin-RPC

Create and consume remote procedure calls in hydra with ease.

Install

$ npm i --save hydra-plugin-rpc

Use

Two methods are added to the hydra instance to add or consume methods

// hydra.methods(obj: Object);
// Object has keys of method names and values of functions.
hydra.methods({
    methodName: (arg1, arg2, arg3) => arg1 + arg2; // return value or Promise
});
// hydra.call(methodName: String, ...arguments) => Promise
// First argument is method name.
// Remaining arguments are sent to method (must be serializable).
// Returns a promise with the result.
hydra.call('methodName', arg1, arg2, arg3).then(...);

Example

// Service1.js
const hydra = require('hydra');
const HydraRPC = require('hydra-plugin-rpc');
const Promise = require('bluebird');

hydra.use(new HydraRPC());

hydra.init({...}).then(() => {
  hydra.methods({
    ping: () => 'pong',
    sleepPing: delay => Promise.resolve('pong').delay(delay) // optionally return promises
  });
});
// Service2.js (even works on separate machines!)
const hydra = require('hydra');
const HydraRPC = require('hydra-plugin-rpc');

hydra.use(new HydraRPC());

hydra.init({...}).then(() => {
  hydra.call('ping').then(result => console.log(result)); // Logs "pong"!
  hydra.call('sleepPing', 1000).then(result => console.log(result)); // Result comes back after 1000 ms!
});

Keywords

hydra

FAQs

Package last updated on 18 May 2017

Did you know?

Socket

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.

Install

Related posts