|
27 | 27 | import io.quarkus.vertx.core.runtime.BufferOutputStream; |
28 | 28 | import io.smallrye.common.annotation.SuppressForbidden; |
29 | 29 | import io.smallrye.mutiny.Uni; |
| 30 | +import io.vertx.core.Future; |
30 | 31 | import io.vertx.core.Handler; |
| 32 | +import io.vertx.core.Promise; |
31 | 33 | import io.vertx.core.Vertx; |
32 | 34 | import io.vertx.core.buffer.Buffer; |
33 | 35 | import io.vertx.core.http.HttpClientOptions; |
@@ -303,12 +305,33 @@ public GrpcStatusCode getStatusCode() { |
303 | 305 |
|
304 | 306 | @Override |
305 | 307 | public String getStatusDescription() { |
306 | | - return status.toString(); |
| 308 | + return status.name(); |
307 | 309 | } |
308 | 310 |
|
309 | 311 | @Override |
310 | 312 | public byte[] getResponseMessage() { |
311 | | - return null;// fixme |
| 313 | + if (response == null) { |
| 314 | + return null; |
| 315 | + } |
| 316 | + Promise<String> promise = Promise.promise(); |
| 317 | + StringBuilder sb = new StringBuilder(); |
| 318 | + response.handler(msg -> { |
| 319 | + sb.append(msg.toString()); |
| 320 | + }); |
| 321 | + response.endHandler(v -> { |
| 322 | + // Done reading stream |
| 323 | + promise.complete(sb.toString()); |
| 324 | + }); |
| 325 | + response.exceptionHandler(promise::fail); |
| 326 | + String result = promise.future() |
| 327 | + .timeout(exportTimeout.toMillis(), MILLISECONDS) |
| 328 | + .recover(throwable -> Future.succeededFuture( |
| 329 | + "Response error: " + throwable.getMessage())) |
| 330 | + .result(); |
| 331 | + if (result == null || result.isEmpty()) { |
| 332 | + return null; |
| 333 | + } |
| 334 | + return result.getBytes(StandardCharsets.UTF_8); |
312 | 335 | } |
313 | 336 | }); |
314 | 337 | } else { |
|
0 commit comments