mirror of https://github.com/grpc/grpc-node.git
grpc native: Fix handling of non-service objects in package definitions
This commit is contained in:
parent
4a9624a81c
commit
f9de2aff7e
|
@ -259,11 +259,20 @@ declare module "grpc" {
|
||||||
readonly [I in keyof ImplementationType]: MethodDefinition<any, any>;
|
readonly [I in keyof ImplementationType]: MethodDefinition<any, any>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An object that defines a protobuf type
|
||||||
|
*/
|
||||||
|
export interface ProtobufTypeDefinition {
|
||||||
|
format: string;
|
||||||
|
type: object;
|
||||||
|
fileDescriptorProtos: Buffer[];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An object that defines a package containing multiple services
|
* An object that defines a package containing multiple services
|
||||||
*/
|
*/
|
||||||
export type PackageDefinition = {
|
export type PackageDefinition = {
|
||||||
readonly [fullyQualifiedName: string]: ServiceDefinition<any>;
|
readonly [fullyQualifiedName: string]: ServiceDefinition<any> | ProtobufTypeDefinition;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -169,7 +169,11 @@ exports.loadPackageDefinition = function loadPackageDefintion(packageDef) {
|
||||||
}
|
}
|
||||||
current = current[packageName];
|
current = current[packageName];
|
||||||
}
|
}
|
||||||
current[serviceName] = client.makeClientConstructor(service, serviceName, {});
|
if (service.hasOwnProperty('format')) {
|
||||||
|
current[serviceName] = service;
|
||||||
|
} else {
|
||||||
|
current[serviceName] = client.makeClientConstructor(service, serviceName, {});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
|
@ -317,9 +317,18 @@ exports.zipObject = function(props, values) {
|
||||||
* @typedef {Object.<string, grpc~MethodDefinition>} grpc~ServiceDefinition
|
* @typedef {Object.<string, grpc~MethodDefinition>} grpc~ServiceDefinition
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An object that defines a protobuf type
|
||||||
|
* @typedef {object} grpc~ProtobufTypeDefinition
|
||||||
|
* @param {string} format The format of the type definition object
|
||||||
|
* @param {*} type The type definition object
|
||||||
|
* @param {Buffer[]} fileDescriptorProtos Binary protobuf file
|
||||||
|
* descriptors for all files loaded to construct this type
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An object that defines a package hierarchy with multiple services
|
* An object that defines a package hierarchy with multiple services
|
||||||
* @typedef {Object.<string, grpc~ServiceDefinition>} grpc~PackageDefinition
|
* @typedef {Object.<string, grpc~ServiceDefinition|grpc~ProtobufTypeDefinition>} grpc~PackageDefinition
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue