| 70 | class MyMongoAdaptor : public brpc::MongoServiceAdaptor { |
| 71 | public: |
| 72 | virtual void SerializeError(int /*response_to*/, butil::IOBuf* out_buf) const { |
| 73 | brpc::mongo_head_t header = { |
| 74 | (int32_t)(sizeof(brpc::mongo_head_t) + sizeof(int32_t) * 3 + |
| 75 | sizeof(int64_t) + EXP_REQUEST.length()), |
| 76 | 0, 0, 0}; |
| 77 | out_buf->append(static_cast<const void*>(&header), sizeof(brpc::mongo_head_t)); |
| 78 | int32_t response_flags = 0; |
| 79 | int64_t cursor_id = 0; |
| 80 | int32_t starting_from = 0; |
| 81 | int32_t number_returned = 0; |
| 82 | out_buf->append(&response_flags, sizeof(response_flags)); |
| 83 | out_buf->append(&cursor_id, sizeof(cursor_id)); |
| 84 | out_buf->append(&starting_from, sizeof(starting_from)); |
| 85 | out_buf->append(&number_returned, sizeof(number_returned)); |
| 86 | out_buf->append(EXP_RESPONSE); |
| 87 | } |
| 88 | |
| 89 | virtual ::brpc::MongoContext* CreateSocketContext() const { |
| 90 | return new MyContext; |