0
0
HLDsystem_design~10 mins

gRPC for internal services in HLD - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a gRPC service method in the proto file.

HLD
service UserService {
  rpc GetUser (GetUserRequest) returns ([1]);
}
Drag options to blanks, or click blank then click option'
AGetUserResponse
BUserRequest
CUserResponseStream
DGetUserStream
Attempts:
3 left
💡 Hint
Common Mistakes
Using request message as response type
Using streaming types incorrectly
2fill in blank
medium

Complete the code to create a gRPC client stub in the service implementation.

HLD
const client = new [1](address, grpc.credentials.createInsecure());
Drag options to blanks, or click blank then click option'
AUserServiceClient
BUserServiceStub
CGrpcClient
DUserClient
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect client class name
Confusing stub with client
3fill in blank
hard

Fix the error in the server handler function signature for unary gRPC call.

HLD
function getUser([1], callback) {
  // handler logic
}
Drag options to blanks, or click blank then click option'
Astream
Brequest
Ccontext
Dcall
Attempts:
3 left
💡 Hint
Common Mistakes
Using request instead of call
Using stream for unary calls
4fill in blank
hard

Fill both blanks to configure a gRPC server with TLS credentials.

HLD
const server = new grpc.Server();
const creds = grpc.ServerCredentials.[1](keyCertPairs, [2]);
server.bindAsync(address, creds, () => server.start());
Drag options to blanks, or click blank then click option'
AcreateSsl
BcreateInsecure
Ctrue
Dfalse
Attempts:
3 left
💡 Hint
Common Mistakes
Using createInsecure for TLS
Setting client cert flag incorrectly
5fill in blank
hard

Fill all three blanks to implement a server streaming gRPC method handler.

HLD
function listUsers([1]) {
  const call = [2];
  users.forEach(user => call.[3](user));
  call.end();
}
Drag options to blanks, or click blank then click option'
Acall
Bnew grpc.ServerWritableStream()
Cwrite
Dsend
Attempts:
3 left
💡 Hint
Common Mistakes
Creating new stream object manually
Using send instead of write