snowdrop-zen / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
1 stars 0 forks source link

Allow using Kotlin Flow for SSE #368

Closed snowdrop-bot closed 3 years ago

snowdrop-bot commented 3 years ago

Description

At the moment in Quarkus it is possible to use Mutiny Multi with the annotation @RestSseElementType to create an endpoint sending events to the client as they are created. Like so:

@RestSseElementType(MediaType.TEXT_PLAIN)
fun doSse(): Multi<String> = Multi.createFrom().
    emitter{ emitter ->
        emitter.emit("One")
        emitter.emit("Two")
        emitter.emit("Three")
        emitter.emit("Four")
        emitter.complete()
    }

Since Quarkus 2.0.0 it is possible to use Kotlin Coroutines with a suspend function for single request.

Support for Kotlin Flow for SSE would be a welcome addition. Something like the following code snippet:

@RestSseElementType(MediaType.TEXT_PLAIN)
fun doFlow(): Flow<String> = flow{
    emit("One")
    emit("Two")
    emit("Three")
    emit("Four")
}

At the moment when using the above code the request returns immediately with a 200 but no values.


https://github.com/quarkusio/quarkus/issues/18201


$upstream:18201$