Page MenuHomePhabricator

[keyserver] add gRPC client module to keyserver
ClosedPublic

Authored by varun on Nov 9 2022, 12:01 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Dec 17, 7:23 AM
Unknown Object (File)
Tue, Dec 17, 7:23 AM
Unknown Object (File)
Tue, Dec 17, 7:23 AM
Unknown Object (File)
Tue, Dec 17, 7:23 AM
Unknown Object (File)
Tue, Dec 17, 7:22 AM
Unknown Object (File)
Tue, Dec 17, 7:19 AM
Unknown Object (File)
Sun, Dec 15, 5:57 AM
Unknown Object (File)
Fri, Nov 29, 1:33 PM

Details

Summary

this module loads the identity.proto file and creates a client for the Identity service.

Depends on D5573

Test Plan

imported the identityClient in keyserver.js and successfully called the getUserPublicKey RPC

Diff Detail

Repository
rCOMM Comm
Branch
get_user_public_key (branched from master)
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

keyserver/src/grpc/grpc_client.js
16 ↗(On Diff #18291)

in a subsequent diff, i'll introduce config that lets us toggle between localhost and the production hostname

Harbormaster returned this revision to the author for changes because remote builds failed.Nov 9 2022, 12:04 PM
Harbormaster failed remote builds in B13339: Diff 18291!
varun requested review of this revision.Nov 10 2022, 4:02 PM

change file name to match convention

tomek requested changes to this revision.Nov 15 2022, 2:57 AM
tomek added inline comments.
keyserver/src/grpc/grpc-client.js
10–14

According to https://www.npmjs.com/package/@grpc/proto-loader it looks that

The following options object closely approximates the existing behavior of grpc.load:

const options = {
  keepCase: true,
  longs: String,
  enums: String,
  defaults: true,
  oneofs: true
}

And it makes me wonder what grpc.load is and if we can use it instead of introducing new library. Especially that we need to provide some configuration to it. Are we sure that these config options are correct for us? Do they affect the objects on client's side, or the data that is sent?

18

We definitely need a place where it can be stored and configured.

19

Why do we use something that isn't secure? What's the difference?

This revision now requires changes to proceed.Nov 15 2022, 2:57 AM

I plan to address config for endpoints and SSL in a subsequent diff. @tomek lmk if you think that needs to precede this diff

keyserver/src/grpc/grpc-client.js
10–14

grpc.load was a method in the now-deprecated C-based gRPC npm package. From the docs:

If you are currently loading .proto files using grpc.load, that function is not available in this library. You should instead load your .proto files using @grpc/proto-loader and load the resulting package definition objects into @grpc/grpc-js using grpc.loadPackageDefinition.
18

yeah, I think I mentioned this in a previous version of this diff. a config file will be added in a subsequent diff

19

this should probably be configurable. createInsecure creates a channel that does not use SSL, which is what we want when we run the Identity service locally. createSsl will need to be used to talk to the production service.

keyserver/src/grpc/grpc-client.js
19

If you agree something should be done, but want to land the diff anyways, you should always link a Linear task tracking that work

tomek added a reviewer: ashoat.
In D5585#167129, @varun wrote:

I plan to address config for endpoints and SSL in a subsequent diff. @tomek lmk if you think that needs to precede this diff

I don't think it matters that much, so feel free to take whatever approach you like.

There's a new dependency included, so adding @ashoat as a blocking reviewer. (for me the dependency looks fine)

keyserver/src/grpc/grpc-client.js
8–17

Just wondering if this shouldn't be included in e.g. a function instead of being directly executed. Not sure if the current approach has significant drawbacks though.

10–14

Thanks for explaining!

18

Haven't seen that comment because it was made when a file had other name - but that makes sense

This revision is now accepted and ready to land.Nov 16 2022, 7:13 PM
keyserver/src/grpc/grpc-client.js
8–17

The current approach is what I saw in other projects, I think it should be fine