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

Method stream

example/http_c++/http_server.cpp:201–221  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

199 }
200
201 void stream(google::protobuf::RpcController* cntl_base,
202 const HttpRequest*,
203 HttpResponse*,
204 google::protobuf::Closure* done) {
205 brpc::ClosureGuard done_guard(done);
206 brpc::Controller* cntl =
207 static_cast<brpc::Controller*>(cntl_base);
208
209 // Send the first SSE response
210 cntl->http_response().set_content_type("text/event-stream");
211 cntl->http_response().set_status_code(200);
212 cntl->http_response().SetHeader("Connection", "keep-alive");
213 cntl->http_response().SetHeader("Cache-Control", "no-cache");
214
215 // Send the generated words with progressiveAttachment
216 std::unique_ptr<PredictJobArgs> args(new PredictJobArgs);
217 args->pa = cntl->CreateProgressiveAttachment();
218 args->input_ids = {101, 102};
219 bthread_t th;
220 bthread_start_background(&th, NULL, Predict, args.release());
221 }
222};
223
224} // namespace example

Callers

nothing calls this directly

Calls 6

bthread_start_backgroundFunction · 0.85
set_content_typeMethod · 0.80
set_status_codeMethod · 0.80
SetHeaderMethod · 0.80
releaseMethod · 0.45

Tested by

no test coverage detected