-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problems when creating own implementation of RawSink/RawSource #235
Comments
@yuroyami thanks for sharing the problem you're tackling with!
The work on publicly accessible API to iterate over buffer's segments and access its internal data is currently in progress, so I hope it will no longer be a problem soon.
I'm not sure if anything significantly different could be done here as both RawSink and RawSource provide blocking API. There is a proposal to support asynchronous IO API in kotlinx-io (#163), but it not yet merged.
What exactly do you mean by "faulty"? Is there a test reproducing a particular issue? |
@fzhinkin Thank you for your prompt response.
Sublime !
The potential integration of 'nio' support would be a valuable enhancement, especially in scenarios like Ktor where asynchronous operations are essential. Closing this issue since the planned points seem sufficient to address the current problem.
I suppose I don't have a particular test to reproduce this issue, but it can be reproduced using Ktor by transmitting dummy data (of any size) from a device to another (server socket and a client socket, pretty basic infrastructure), seems like a Ktor issue when I read its channel blockingly, so it's not related to kotlinx-io. The latter does the job perfectly when I am not using a custom implementation for the RawSink. |
Trying to bridge Ktor and Kotlinx.io together, which for the time being is not available via either libraries, so I had to implement my own workaround. These are the issues that I faced along the way:
Problem no.1 - Most of the properties for
Buffer
are internal/private : In order to create my own implementation to make sure efficiency is not an issue, I wanted to create something close to JVMInputStream.asSource()
andOutputStream.asSink()
extension functions, but most of buffer properties are internal or private (tail, head, etc).Problem no.2 - Bridging is more problematic when the receiver needs suspend-able writing/reading: which is the case with Ktor's
ByteReadChannel
andByteWriteChannel
, where I end up forced to userunBlocking
.Here's my bridging workaround, the reading seems to work OK, but writing is faulty. I wrap both of them with
buffered()
. Any ideas ?The text was updated successfully, but these errors were encountered: