MCPcopy Create free account
hub / github.com/apache/brpc / SerializeSofaHeaderAndMeta

Function SerializeSofaHeaderAndMeta

src/brpc/policy/sofa_pbrpc_protocol.cpp:143–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

141}
142
143static void SerializeSofaHeaderAndMeta(
144 butil::IOBuf* out, const SofaRpcMeta& meta, int payload_size) {
145 const uint32_t meta_size = GetProtobufByteSize(meta);
146 if (meta_size <= 232) { // most common cases
147 char header_and_meta[24 + meta_size];
148 PackSofaHeader(header_and_meta, meta_size, payload_size);
149 ::google::protobuf::io::ArrayOutputStream arr_out(header_and_meta + 24, meta_size);
150 ::google::protobuf::io::CodedOutputStream coded_out(&arr_out);
151 meta.SerializeWithCachedSizes(&coded_out); // not calling ByteSize again
152 CHECK(!coded_out.HadError());
153 out->append(header_and_meta, sizeof(header_and_meta));
154 } else {
155 char header[24];
156 PackSofaHeader(header, meta_size, payload_size);
157 out->append(header, sizeof(header));
158 butil::IOBufAsZeroCopyOutputStream buf_stream(out);
159 ::google::protobuf::io::CodedOutputStream coded_out(&buf_stream);
160 meta.SerializeWithCachedSizes(&coded_out);
161 CHECK(!coded_out.HadError());
162 }
163}
164
165ParseResult ParseSofaMessage(butil::IOBuf* source, Socket* socket,
166 bool /*read_eof*/, const void* /*arg*/) {

Callers 2

SendSofaResponseFunction · 0.85
PackSofaRequestFunction · 0.85

Calls 4

GetProtobufByteSizeFunction · 0.85
PackSofaHeaderFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected