armeria icon indicating copy to clipboard operation
armeria copied to clipboard

Provide a way to adapt `StreamMessage` into `InputStream` or `OutputStream`

Open trustin opened this issue 4 years ago • 5 comments

e.g.

Publisher<HttpData> reactive = ...;
InputStream in = reactive.toInputStream(); // Creates a subscription.
in.read();
...
StreamMessageWriter<HttpData> reactive = ,,,;
OutputStream out = reactive.asOutputStream();
objectMapper.writeValue(out, myJsonObject);

trustin avatar Oct 02 '20 08:10 trustin

Get inspiration/copy everything from here. https://gist.github.com/tobias-/b4841f021374e7cb90b9484f49b49bec

Use and abuse the code linked as you like, I don't consider myself the author of this small chunk of code more than a plumber is the author of laying pipes at certain angles.

Caveat, the code works (at least in it's kotlin form), but there are possible issues with thread-pools, as I know next to nothing about that in Armeria

tobias- avatar Oct 02 '20 08:10 tobias-

I've written something similar here too in case it helps :) https://github.com/burrunan/gradle-s3-build-cache/pull/6/commits/fb99b928e64f6f4d2101f68b01980c794af36dc5

anuraaga avatar Oct 02 '20 08:10 anuraaga

I'll try this issue!

injae-kim avatar Dec 03 '21 02:12 injae-kim

2022-01-25

  • Discuss some implementation issues on armeria slack(link)

injae-kim avatar Jan 11 '22 07:01 injae-kim

FYI, We found some bug on StreamMessageInputStream so now fixing it on https://github.com/line/armeria/pull/4271. Please check https://github.com/line/armeria/issues/4268 for the details.

injae-kim avatar Jun 10 '22 13:06 injae-kim