Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@phiresky/redis-remotify

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@phiresky/redis-remotify

a tiny library for remote calls and events via redis

  • 0.2.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

redis-remotify

A tiny library for remote calls and events via redis.

Install via npm:

yarn add @phiresky/redis-remotify

Example use

Say you have a backend like this:

class Squarer {
	public async square(x: number) {
		// maybe do some more interesting stuff here
		return x ** 2;
	}
}

But you want to use the functions it provides in different processes. With this library, you can start a server process like this:

import * as redis from "redis";
import { Listen } from "@phiresky/redis-remotify";

const squarer = new Squarer();

const pub = redis.createClient();
const sub = redis.createClient();
const r = new Listen("backend", { pub, sub });
// add methods to RPC interface with a name like Squarer.square()
r.listenAll(squarer);

And then call the functions from one or more separate node processes like this:

import { Remotify } from "@phiresky/redis-remotify";

const backend = new Remotify("backend", { pub, sub });
const remoteSquarer = backend.remotifyClass(Squarer);
for (const x of [1, 2, 3, 4, 5, 11]) {
	const res = await remoteSquarer.square(x);
	// typeof res is number as expected
	console.log(x, "^2 =", res);
}

Of course it also works with single functions or other non-class objects. A more complete example can be seen in examples/elaborate.ts.

FAQs

Package last updated on 05 Apr 2020

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc