[SERVER-19451] Unify message creation for OP_REPLY and OP_COMMANDREPLY messages Created: 16/Jul/15  Updated: 05/Apr/17  Resolved: 05/Jul/16

Status: Closed
Project: Core Server
Component/s: Networking
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Misha Tyulenev Assignee: Misha Tyulenev
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Sprint: Platform 8 08/28/15, Platform 7 08/10/15
Participants:

 Description   

The Issue

Currently replies to the find and getMore commands and queries in mongod and mongos explicitly construct the respond message. This gives flexibility in enforcing size restrictions and managing memory but is error prone, not flexible and can not support multiple output formats required for different wired versions.

The Goal

  • Provide a uniform approach to constructing all messages that are sent out
    as an OP_REPLY or OP_COMMANDREPLY.
  • Implement run time transformation of the message to any version of the output wired protocol.

Proposed Implementation

Refactor existing ReplyBuilderInterface and derived classes.
Add a new class

template <class SizePolicy>
class ReplyMessage: private SizePolicy {

that will be used to construct a message. Its a policy host that can be customized with different policy for size checks, initial buffer size, and
other properties known at the compile time.

Refactor ReplyBuilderInterface for building the reply of the desired type from ReplyMessage.

The intended usage is

// build a message
ReplyMessage<SizeCheckingPolicy> reply;
...
reply.addOutputDocument(doc);
...
auto builder = rpc::makeReplyBuilder(protocol);
auto message = builder->build(reply);



 Comments   
Comment by Misha Tyulenev [ 05/Jul/16 ]

The proposal was abandoned after the discussion and review.

Comment by Githook User [ 08/Oct/15 ]

Author:

{u'username': u'mikety', u'name': u'Misha Tyulenev', u'email': u'misha@mongodb.com'}

Message: SERVER-19451 refactor RPC to use ReplyMessage: Interfaces lint
Branch: SERVER-19451
https://github.com/mongodb/mongo/commit/8b76052bfd4753ad17eb083cb89f1de4a91cf570

Comment by Githook User [ 08/Oct/15 ]

Author:

{u'username': u'mikety', u'name': u'Misha Tyulenev', u'email': u'misha@mongodb.com'}

Message: SERVER-19451 refactor RPC to use ReplyMessage: Interfaces
Branch: SERVER-19451
https://github.com/mongodb/mongo/commit/007488bfb733303b7bc4910ac7c134939b1691a7

Generated at Thu Feb 08 03:51:01 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.