MCPcopy Create free account
hub / github.com/FoundationDB/fdb-document-layer / ExtMsgReply

Class ExtMsgReply

src/ExtMsg.actor.h:94–142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92};
93
94struct ExtMsgReply : ExtMsg, FastAllocated<ExtMsgReply> {
95 enum { opcode = 1 };
96
97 ExtMsgHeader* header;
98 bson::BSONObj query;
99 std::vector<bson::BSONObj> documents;
100
101 ExtReplyHeader replyHeader;
102
103 // For constructing our own replies, rather than parsing a reply
104 // off of the wire
105 ExtMsgReply(ExtMsgHeader*, bson::BSONObj const& query);
106 explicit ExtMsgReply(ExtMsgHeader*);
107
108 std::string toString() override;
109 Future<Void> run(Reference<ExtConnection>) override { UNREACHABLE(); }
110
111 void addDocument(bson::BSONObj doc) {
112 documents.push_back(doc.getOwned());
113 replyHeader.documentCount++;
114 }
115
116 void setError(std::string msg, int code) {
117 // Clear if response contains any outstanding documents
118 documents.clear();
119 replyHeader.documentCount = 0;
120
121 // Set query failure flag
122 addResponseFlag(2);
123
124 // clang-format off
125 addDocument(BSON("ok" << 0 <<
126 "$err" << msg <<
127 "code" << code));
128 // clang-format on
129 }
130
131 void setError(Error e) { setError(e.what(), e.code()); }
132
133 void setResponseFlags(int32_t flags) { replyHeader.responseFlags = flags; }
134
135 void addResponseFlag(int32_t flag) { replyHeader.responseFlags = replyHeader.responseFlags | flag; }
136
137 void write(Reference<ExtConnection>);
138
139private:
140 ExtMsgReply(ExtMsgHeader*, const uint8_t*);
141 friend struct ExtMsg::Factory<ExtMsgReply>;
142};
143
144struct ExtUpdateCmd {
145 bson::BSONObj selector;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected