| 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 |
nothing calls this directly
no test coverage detected