@keeveeg/rpc
v1.1.0
Published
Remote Procedure Call (RPC)
Downloads
17
Readme
Remote Procedure Call (RPC)
Installation
$ npm install @keeveeg/rpc
Master
Create instance
import { rpcMaster } from '@keeveeg/rpc'
const master = new rpcMaster()
Add worker
await master.addWorker('http://other-url', 44441)
Exectute function
Only arrow functions supported
const sum = (a, b) => a + b
const result = await master.exec(sum, 1, 2) // 3
Install modules
await master.addModule('axios')
Use dynamic import in executable function
const func = async url => {
const { default: axios } = await import('axios')
const { status } = await axios.get(url)
return status
}
const result = await master.exec(func, 'https://github.com/KeeVeeG')
Worker
Create instance on other machine
import { rpcWorker } from '@keeveeg/rpc'
new rpcWorker(44441)