gordonmu-coio

A library for a simple coroutine IO API, wrapping efficient non-blocking Java IO libs for easy use.

Лицензия

Лицензия

Группа

Группа

io.github.gordonmu
Идентификатор

Идентификатор

gordonmu-coio
Последняя версия

Последняя версия

0.8.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

gordonmu-coio
A library for a simple coroutine IO API, wrapping efficient non-blocking Java IO libs for easy use.
Ссылка на сайт

Ссылка на сайт

https://github.com/gordonmu/coio
Система контроля версий

Система контроля версий

https://github.com/gordonmu/coio

Скачать gordonmu-coio

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/io.github.gordonmu/gordonmu-coio/ -->
<dependency>
    <groupId>io.github.gordonmu</groupId>
    <artifactId>gordonmu-coio</artifactId>
    <version>0.8.0</version>
</dependency>
// https://jarcasting.com/artifacts/io.github.gordonmu/gordonmu-coio/
implementation 'io.github.gordonmu:gordonmu-coio:0.8.0'
// https://jarcasting.com/artifacts/io.github.gordonmu/gordonmu-coio/
implementation ("io.github.gordonmu:gordonmu-coio:0.8.0")
'io.github.gordonmu:gordonmu-coio:jar:0.8.0'
<dependency org="io.github.gordonmu" name="gordonmu-coio" rev="0.8.0">
  <artifact name="gordonmu-coio" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.github.gordonmu', module='gordonmu-coio', version='0.8.0')
)
libraryDependencies += "io.github.gordonmu" % "gordonmu-coio" % "0.8.0"
[io.github.gordonmu/gordonmu-coio "0.8.0"]

Зависимости

runtime (5)

Идентификатор библиотеки Тип Версия
org.jetbrains.kotlin : kotlin-stdlib-jdk8 jar 1.4.20
org.jetbrains.kotlinx : kotlinx-coroutines-core-jvm jar 1.4.2
org.jetbrains.kotlinx : kotlinx-coroutines-jdk8 jar 1.4.2
io.github.microutils : kotlin-logging jar 1.8.3
org.slf4j : slf4j-api jar 1.7.30

test (7)

Идентификатор библиотеки Тип Версия
org.assertj : assertj-core jar 3.17.2
org.junit.jupiter : junit-jupiter-api jar 5.6.2
io.mockk : mockk jar 1.10.0
org.awaitility : awaitility jar 4.0.3
org.awaitility : awaitility-kotlin jar 4.0.3
org.junit.jupiter : junit-jupiter-engine jar 5.6.2
org.apache.logging.log4j : log4j-slf4j-impl jar 2.13.3

Модули Проекта

Данный проект не имеет модулей.

Java CI Download

CoIO

Kotlin Coroutines make asynchronous programming simple and efficient but there is no official library that provides IO operations in a coroutine. These operations, such as reading a file or sending data over a TCP connection, benefit heavily from coroutines because they can take relatively long and use few CPU resources. This library seeks to wrap existing Java non-blocking IO libraries to provide a uniform and simple API with coroutines.

Features

  • Simple, lean stream interfaces with suspend read and write functions using ByteBuffers
  • Supports file access
  • Supports TCP servers and clients
  • Supports UDP unicast and multicast
  • Wrapping any stream with TLS

Alternatives

  • Official Kotlin coroutine IO - Does not exist yet.
  • Java blocking IO - Must be used with care in coroutines because the blocking operations can consume your worker threads. Consider using the IO Dispatcher.
  • Java NIO - Efficient non-blocking operation available but steep learning curve and quite a bit of code needed to build coroutines.
  • Java NIO2 - Nice asynchronous methods that can be easily wrapped into a coroutine.

Usage

TCP Server

val server = CoIOTcp.listen(8775)

for (connection in server) {
    launch {
        val buf = ByteBuffer.allocate(1024)
        connection.readFully(buf)
        buf.flip()
        connection.writeFully(buf)
    }
}

Версии библиотеки

Версия
0.8.0