diff --git a/src/grpc.ts b/src/grpc.ts index dfca09aea..f20e209da 100644 --- a/src/grpc.ts +++ b/src/grpc.ts @@ -78,7 +78,6 @@ export interface Metadata { export type GrpcModule = typeof grpcTypes&{ status: {[index: string]: number;}; - isLegacy: boolean; }; export interface ClientStubOptions { @@ -128,11 +127,9 @@ export class GrpcClient { if (semver.gte(process.version, '8.13.0') && !!process.env.GOOGLE_CLOUD_USE_GRPC_JS) { this.grpc = require('@grpc/grpc-js'); - this.grpc.isLegacy = false; this.grpcVersion = require('@grpc/grpc-js/package.json').version; } else { this.grpc = require('grpc'); - this.grpc.isLegacy = true; this.grpcVersion = require('grpc/package.json').version; } } @@ -172,28 +169,13 @@ export class GrpcClient { /** * Load grpc proto service from a filename hooking in googleapis common protos - * when necessary. Uses legacy grpc.loadObject. + * when necessary. * @param {String} protoPath - The directory to search for the protofile. * @param {String} filename - The filename of the proto to be loaded. * @return {Object} The gRPC loaded result (the toplevel namespace * object). */ - protected loadProtoLegacy(protoPath: string, filename: string) { - const resolvedPath = GrpcClient._resolveFile(protoPath, filename); - const retval = this.grpc.loadObject( - protobuf.loadSync(resolvedPath, new GoogleProtoFilesRoot())); - return retval; - } - - /** - * Load grpc proto service from a filename hooking in googleapis common protos - * when necessary. Uses the new shiny @grpc/proto-loader. - * @param {String} protoPath - The directory to search for the protofile. - * @param {String} filename - The filename of the proto to be loaded. - * @return {Object} The gRPC loaded result (the toplevel namespace - * object). - */ - protected loadProtoGrpcJs(protoPath: string, filename: string) { + loadProto(protoPath: string, filename: string) { // This set of @grpc/proto-loader options // 'closely approximates the existing behavior of grpc.load' const includeDirs = INCLUDE_DIRS.slice(); @@ -209,20 +191,6 @@ export class GrpcClient { return this.loadFromProto(filename, options); } - /** - * Load grpc proto service from a filename hooking in googleapis common protos - * when necessary. Can use either legacy grpc.loadProto, or new - * @grpc/proto-loader, depending on which gRPC backend is used. - * @param {String} protoPath - The directory to search for the protofile. - * @param {String} filename - The filename of the proto to be loaded. - * @return {Object} The gRPC loaded result (the toplevel namespace - * object). - */ - loadProto(protoPath: string, filename: string) { - return this.grpc.isLegacy ? this.loadProtoLegacy(protoPath, filename) : - this.loadProtoGrpcJs(protoPath, filename); - } - static _resolveFile(protoPath: string, filename: string) { if (fs.existsSync(path.join(protoPath, filename))) { return path.join(protoPath, filename);