1.1.0 • Published 2 years ago

@keeveeg/rpc v1.1.0

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

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)
1.1.0

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago