let ep_my_api = hub.rpc.endpoint({
// rpc methods
m$_alpha(rpcx, ...args) { /* ... */ },
m$_beta(rpcx, ...args) { /* ... */ },
'another rpc method'(rpcx, ...args) { /* ... */ },
})
-
RPC Client
to(id, meta?, {...kw})
creates a directed RPC client to theid
.meta
andkw
are optional.client
is a prototypal instace of rpc client with the target router
-
RPC
is the RPC API dispatcher strategy class -
api
creates an instance of the RPC API dispatcher -
stream(xtgt, rpc_api)
-
endpoint(id_target?, rpc_api)
-
ep_stateful(id_target?, rpc_api)
-
ep_idempotent(id_target?, rpc_api)
-
from()
andhub.rpc_from()
-- binds a new RPC context using the specified target router.
hub.rpc.api({
// rpc methods
m$_alpha(rpcx, ...args) { /* ... */ },
m$_beta(rpcx, ...args) { /* ... */ },
'another rpc method'(rpcx, ...args) { /* ... */ },
// optional override of rpc flow:
rpc_lookup(rpc_call) {
return this[rpc_call.method] },
rpc_log(rpc_call, step, ...info) {
console.log('rpc log [%o]', rpc_call.method, step, info) },
rpc_dnu(rpc_call)`
console.warn('rpc dnu [%o]', rpc_call.method) },
rpc_error(err, rpc_call) {
console.warn('rpc error [%o]', rpc_call.method, err) },
})
-
.rpc_post(method, ...args)
-
.post.m$_method(...args)
-
.rpc_query(method, ...args)
-
.query.m$_method(...args)
-
.to(id, meta, {... kw}?)
-
.with({...kw})
-
static create(rpc_api)
-
new RPC(rpc_api)
constrcutor -
async rpc_stream(xtgt)
-
async rpc_pkt(pkt, pktctx)
-
Overridable on
rpc_api
as well as RPCrpc_lookup(rpc_call)
resolve method onrpc_api
or undefined.rpc_log(rpc_call, step, ...info)
rpc_error(err, rpc_call)
rpc_dnu(rpc_call)
-
bind_rpc(rpc_call, pktctx)
Givenrpc_call
of shape['!', id_reply, method, ... args]
, resolve usingrpc_lookup
. Returns undefined ifrpc_call
ormethod
name are invalid.