mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 02:47:34 +00:00
perf(rpc): stop the dispatcher importing every RPC method by default (#39669)
* perf(rpc): stop the dispatcher importing every RPC method by default Callers pass the method list. A test that builds a dispatcher no longer loads the full method registry, cutting the dispatcher's import graph from ~4k to ~550 modules. * chore(lint): keep the RPC dispatcher and plugin RPC off the method registry --------- Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
This commit is contained in:
@@ -19,11 +19,11 @@ export class PluginRuntimeRpcError extends Error {
|
||||
*/
|
||||
export function pluginRuntimeRpc(
|
||||
runtime: OrcaRuntimeService,
|
||||
methods?: DispatcherOptions['methods']
|
||||
methods: DispatcherOptions['methods']
|
||||
): PluginRuntimeRpc {
|
||||
let dispatcher: RpcDispatcher | null = null
|
||||
return async (method, params, options = {}) => {
|
||||
dispatcher ??= new RpcDispatcher({ runtime, ...(methods ? { methods } : {}) })
|
||||
dispatcher ??= new RpcDispatcher({ runtime, methods })
|
||||
// The dispatcher maps a throw to an error answer; keep the original so its code reaches the plugin.
|
||||
let refusal: unknown = null
|
||||
const response = await dispatcher.dispatch(
|
||||
|
||||
Reference in New Issue
Block a user