-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
Networking & Observability
Right now, the GRPCReactor is friends with the StubFactory and EgressSession types to indicate that they are allowed to schedule onto the completion queue via
_registerCompletionQueueEntry. A more ideal design might look like:
- We have a new GRPCCompletionQueue type, with a private constructor.
- The GRPCTransportLayer is the only class allowed to construct the GRPCCompletionQueue.
- There is a private GRPCReactor::_getCompletionQueue() method which returns the GRPCCompletionQueue associated with a reactor, that only the GRPCTransportLayer is allowed to access. It then passes that completion queue down to all classes which need it (StubFactory, EgressSession, MockClient).
- The GRPCCompletionQueue has two methods in addition to Next and Shutdown-- Future<std::shared_ptr<ClientStream>> makeStream and Future<void> startWork. These appropriately implement shutdown safety, etc, and obscure the details of the CQ from callers.
- This way, any class that has a reactor can schedule work onto it without seeing the details of CQ tags.
This would also allow us to mock the CompletionQueue, which would make our MockClient align with the GRPCClient a little better (right now the mock fulfills its own promise, rather than having the completion queue do that for it).
This isn't strictly required for correctness, but if we expand the usages of gRPC it may make the code easier to maintain.