Skip to content
This repository was archived by the owner on Nov 18, 2025. It is now read-only.

refactor: add dependency on @grpc/proto-loader#229

Merged
kjin merged 4 commits intogoogleapis:masterfrom
kjin:grpc-proto-loader
Jul 23, 2018
Merged

refactor: add dependency on @grpc/proto-loader#229
kjin merged 4 commits intogoogleapis:masterfrom
kjin:grpc-proto-loader

Conversation

@kjin
Copy link
Contributor

@kjin kjin commented May 15, 2018

Fixes googleapis/google-cloud-node-core#462

This PR removes usages of grpc.load and grpc.loadObject, replacing them with the new @grpc/proto-loader package.

As it stands currently, this will not pass tests. This is because loadProto asks a lot of its return value -- it must be a gRPC client, but it also must have protobufjs-related fields on it. The new implementation of load intentionally moves away from this interface because of its dependency on the surface types of protobufjs. Therefore, I think the tests that check the return value of loadProto should be re-evaluated.

I'm in the process of testing to make sure client libraries still have the same behavior. In the meantime, I wanted to start a discussion on the loadProto issue here.

@kjin kjin requested review from a team and JustinBeckwith May 15, 2018 23:19
src/grpc.ts Outdated
load(
filename: GrpcLoadFileArg|GrpcLoadArgs, _?: null,
options?: GrpcLoadOptions): grpc.GrpcObject {
if ((Array.isArray as (x) => x is GrpcLoadArgs)(filename)) {

This comment was marked as spam.

This comment was marked as spam.

src/grpc.ts Outdated
filename = filename[0] as GrpcLoadFileArg;
}
let root: string|null = null;
if (typeof filename !== 'string') {

This comment was marked as spam.

src/grpc.ts Outdated
options = filename[2] || filename[1] || {};
filename = filename[0] as GrpcLoadFileArg;
}
let root: string|null = null;

This comment was marked as spam.

test/grpc.ts Outdated
});
});

// TODO: Re-evaluate what the contract of loadProto is.

This comment was marked as spam.

@kjin kjin force-pushed the grpc-proto-loader branch 3 times, most recently from 19f92ac to a1ad021 Compare June 23, 2018 00:05
Copy link
Contributor

@JustinBeckwith JustinBeckwith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM


it('should load the test file', () => {
const protos = grpcClient.loadProto(TEST_PATH, TEST_FILE);
// tslint:disable-next-line:no-any

This comment was marked as spam.

This comment was marked as spam.

@kjin kjin force-pushed the grpc-proto-loader branch from a323fa5 to 447dc89 Compare June 26, 2018 17:37
@jkwlui
Copy link
Member

jkwlui commented Jul 10, 2018

Any updates on the status of this refactor?

@kjin
Copy link
Contributor Author

kjin commented Jul 16, 2018

@kinwa91 Sorry, this flew under my radar. Seems like things are failing due to a change I made in gRPC types recently, so I'll need to go update the dependencies.

@kjin kjin force-pushed the grpc-proto-loader branch from 7f3f0b8 to 2fc8bda Compare July 18, 2018 22:09
@kjin kjin force-pushed the grpc-proto-loader branch from 2fc8bda to fae8753 Compare July 19, 2018 17:22
@kjin
Copy link
Contributor Author

kjin commented Jul 19, 2018

We were blocked by a PBJS TypeScript change. Now that it's been released, hopefully tests should pass now.

@kjin kjin force-pushed the grpc-proto-loader branch from fae8753 to b930f46 Compare July 20, 2018 22:25
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants