sofa-rpc-node/lib/util/proto_util.js
2018-09-11 22:29:32 +08:00

19 lines
502 B
JavaScript

'use strict';
const methodMap = new Map();
exports.getMethodInfo = (proto, interfaceName, methodName) => {
const key = interfaceName + '#' + methodName;
let method = methodMap.get(key);
if (!method) {
const service = proto.lookupService(interfaceName);
method = service.get(methodName);
if (!method) {
throw new Error(`no such Method '${methodName}' in Service '${interfaceName}'`);
}
method = method.resolve();
methodMap.set(key, method);
}
return method;
};