Coder Social home page Coder Social logo

Comments (10)

BppleMan avatar BppleMan commented on June 2, 2024 3

Now, we can migrate to kotlinx-io
https://youtrack.jetbrains.com/issue/KTOR-6030/Migrate-to-new-kotlinx.io-library

from kommand.

BppleMan avatar BppleMan commented on June 2, 2024

You're right, but I'm considering whether to use okio, which is a standalone io library that might be easier for users to learn. If I'm not going to expose any 3rd party io, maybe I really need fully encapsulated io. Do you have more views on this?

from kommand.

Jeffset avatar Jeffset commented on June 2, 2024

Thanks for the reply! I think, fully incapsulating IO is a great idea, go with it if you can. This way you can decide on what actual IO backend to use and update without introducing breaking changes for the clients.

from kommand.

BppleMan avatar BppleMan commented on June 2, 2024

I have been thinking about this issue recently. Now kotlin-multiplatform does not have a standard io protocol or implementation. Although ktor-io belongs to the first-party library, it is not in the stdlib, which creates a problem. If every third-party library Providing your own set of io standards is very unfriendly to users. Every time users use a library, they need to learn the io api corresponding to the library. This is really ugly, so I considered using ktor-io at the beginning. But before kotlin officially proposes any standard library implementation, I don't think more io implementations should be added, which is meaningless work

from kommand.

BppleMan avatar BppleMan commented on June 2, 2024

Anyone can discuss below

from kommand.

sanyavertolet avatar sanyavertolet commented on June 2, 2024

In our projects we use square/okio which is nice (has 8k stars). At least, it seems more popular, so it might be better to use it, nevertheless, I'm not sure it fits you

from kommand.

BppleMan avatar BppleMan commented on June 2, 2024

In our projects we use square/okio which is nice (has 8k stars). At least, it seems more popular, so it might be better to use it, nevertheless, I'm not sure it fits you

Using okio I think is acceptable, But more votes are needed

from kommand.

BppleMan avatar BppleMan commented on June 2, 2024

this is a poll
#8

from kommand.

sanyavertolet avatar sanyavertolet commented on June 2, 2024

Any updates here?

from kommand.

BppleMan avatar BppleMan commented on June 2, 2024

In fact, the current approach is a simple io encapsulation, and the exposed APIs are readLine and lines.

open class Reader (
private val platformReader: PlatformReader
) : Input(
// pool = DefaultBufferPool(Buffer.ReservedSize + 1, 1)
) {
override fun closeSource() {
platformReader.closeSource()
}
override fun fill(destination: Memory, offset: Int, length: Int): Int {
return platformReader.fill(destination, offset, length)
}
fun readLine(): String? {
return readUTF8Line()
}
fun lines(): Sequence<String> {
return sequence {
while (endOfInput.not()) {
readUTF8Line()?.let { yield(it) }
}
}
}
}

ktor-io only acts as a middle layer. It neither makes real system calls nor uses its external API. It only acts as a buffer to assist the above API.

Therefore no changes will be made for now, the api is simple enough to provide full functionality

from kommand.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.