rsocket-kotlin icon indicating copy to clipboard operation
rsocket-kotlin copied to clipboard

Research usage of big Payloads

Open whyoleg opened this issue 5 years ago • 6 comments

On current moment Payload contains 2 properties data and metadata which can store bytes. The problem is, that those properties store ByteReadPacket which works like in-memory buffer. So f.e. to send big file through in one Payload(+fragmentation), it will be needed to firstly read everything from file to ByteReadPacket, so in memory.

Need to research, if and how it's possible to send such big payloads without reading everything to memory

whyoleg avatar Oct 18 '20 10:10 whyoleg

My mental model has been around an individual payload being available via a stream API, like Channel<ByteReadPacket>, InputStream/OutputStream or similar.

yschimke avatar Oct 18 '20 10:10 yschimke

For inspiration: ktor-io byte channels Also it has integration with File IO and JVM IO-streams.

whyoleg avatar Oct 18 '20 10:10 whyoleg

I'd be interested in hooking it into the CLI once it's barely working. Can testing with streaming STDIN/STDOUT pipes etc.

yschimke avatar Oct 18 '20 11:10 yschimke

better to postpone this task until ktor/ktor-io will have 2.0.0 version, which will change some Input API.

olme04 avatar Jul 21 '21 10:07 olme04

POC api change: https://github.com/olme04/rsocket-kotlin/commit/5946241c3997cf3f711152d37ddd2b05719d19e3#diff-b20323f12dc29bebdc7845234a305c8f22b468cb7c98964cb14ad808696ec65f Main breaking change is that when using Input instead of BRP we will loose possibility to copy payload (or data/metadata). This will affect user code.

olme04 avatar Aug 07 '21 07:08 olme04

Someday I think we will need to migrate to https://github.com/Kotlin/kotlinx-io/issues/131, though, it depends on how well it will interop with ktor and so ktor-io, as this is the main transport now.

whyoleg avatar Jun 14 '23 15:06 whyoleg