This package has been deprecated

Author message:

This package is dormant

@ctx-core/rpc
TypeScript icon, indicating that this package has built-in type declarations

3.1.0 • Public • Published

RPC

This package is dormant & stripped of functionality, due to ctx-core moving away from Agent objects & using Store instead.


A Remote Procedure Call (rpc) mechanism.

rpc provides an api which exposes functions as a service, while wrapping operations to run auth & whitelist public data.

Since rpc maps to functions, rpc can be a technique of modularizing & composing server code.

Why not just use REST?

In this rpc architecture, REST is used to access call__rpc via POST /rpc in ctx-core/rpc/koa.

rpc is a more primitive network protocol, allowing functions to be directly called.

These same functions may also be wrapped in a RESTful resource.

This of this as composable controller functions or a layer under koa http handlers.

Multiple rpc calls may be invoked & run in parallel or in sequence using a simple functional interface.

Representing a RESTful api as rpc (RESTful prototypes & Refactoring)

With a naming convention, you can depict a RESTful request using a simple function.

get__quovo__account__portfolios simulates GET https://api.quovo.com/v2/accounts/:account_id/portfolios on the server.

Refactoring these methods provides a lightweight way to discover the appropriate RESTful endpoints.

Server

A rpc is run on the server using run__rpc in ctx-core/rpc/lib.

RESTful (koa) request handlers can run__rpc to reuse code & get the benefits of rpc services.

Client

Client Request

A rpc is called on the client via a HTTP POST /rpc accepting json:

{
	"rpc": ["rpc1", "rpc2", "rpc3"],
	"authentication": "{string|Object}",
	"sample_key_1": "sample_value_1",
	"sample_key_2": "sample_value_2",
	"sample_key_3": "sample_value_3"
}

The rpc array calls are run in parallel on the first dimension of the array.

The data in the json may set the rpc ctx after being filtered through the run__rpc whitelist in ctx-core/rpc/lib.

In the future, a second dimension may be added to run those rpc calls in sequence.

Client Response

A successful response will by the ctx to be handled by the client.

Readme

Keywords

Package Sidebar

Install

npm i @ctx-core/rpc

Weekly Downloads

1

Version

3.1.0

License

Apache-2.0

Unpacked Size

3.64 kB

Total Files

8

Last publish

Collaborators

  • btakita