Skip to content
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

Allow using Kotlin Flow for SSE #18201

Closed
a-frank opened this issue Jun 28, 2021 · 4 comments · Fixed by #18222
Closed

Allow using Kotlin Flow for SSE #18201

a-frank opened this issue Jun 28, 2021 · 4 comments · Fixed by #18222
Assignees
Milestone

Comments

@a-frank
Copy link

a-frank commented Jun 28, 2021

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.

@a-frank a-frank added the kind/enhancement New feature or request label Jun 28, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Jun 28, 2021

/cc @evanchooly

@geoand
Copy link
Contributor

geoand commented Jun 28, 2021

This would be a nice enhancement for RESTEasy Reactive.

Do you want to look into it @evanchooly or should I?

@eldimious
Copy link

+1

@geoand
Copy link
Contributor

geoand commented Jun 29, 2021

This part introduces support: #18222

It's a good start, but will certainly need more community testing when / if it gets in

@geoand geoand self-assigned this Jun 29, 2021
geoand added a commit to geoand/quarkus that referenced this issue Jul 2, 2021
geoand added a commit that referenced this issue Jul 5, 2021
Introduce support for Kotlin Flow as return type in RESTEasy Reactive
@quarkus-bot quarkus-bot bot added this to the 2.1 - main milestone Jul 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants