armeria
armeria copied to clipboard
Provide a way to adapt `StreamMessage` into `InputStream` or `OutputStream`
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);
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
I've written something similar here too in case it helps :) https://github.com/burrunan/gradle-s3-build-cache/pull/6/commits/fb99b928e64f6f4d2101f68b01980c794af36dc5
I'll try this issue!
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.