Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-98339

Remove friendship from GRPCReactor Design

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 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.

            Assignee:
            Unassigned Unassigned
            Reporter:
            erin.mcnulty@mongodb.com Erin McNulty
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: