smallrye-mutiny
smallrye-mutiny copied to clipboard
Kotlin types are lost on specific operations
With kotlin and smallyre sometimes I need to declare the type again.
Additional details
Examples:
-
.transformToMulti { fetch(it.bananas).onItem().disjoint<Banana>() }
Without<Banana>
it doesn't know that I fetch the Bananas. -
.call { it -> if (it.type?.entityType == Apple) serviceApple.updateBy(it) else createUniFrom().nullItem<Apple>() }
Without<Apple>
it doesn't know that it should return a nullItem with this type. But shouldn't it know it already, because I return an Uni<Apple> in the true case? PS:nullItem<Void>
andnullItem<Unit>
are working too, which confuses me more. There is.voidItem()
, but that I would otherwise need to declare the type confuses me. Maybe the java code of smallrye confuses kotlin?
Maybe we need kotlin classes as a layer in smallrye which optimize the kotlin compatibility? As far as I know the Quarkus Framework uses this approach.
PS: I like the word confusing
Like the idea and would love to investigate, unfortunately, I'm blocked for the next month. @MartinX3 how about meet at https://www.cloudland.org/ and discuss in person? ;)
@heubeck Sadly it's too expensive for me and I use Mutiny only for my job. I don't use it in my volunteer tasks and my studies, so I also don't have time as well.
I found a new issue
It needs the type for the mapping function.
So .map(List<Double>::average)
and .map { it.average() }
are working, but .map(::average)
throws an error.
fun findAverageScoreByA(id: UUID): Uni<Double> =
stream("b.aId", id).group().by { it.category.name }
.onItem().transformToUniAndMerge { it.collect().asList() }.map { it.map(b::score).average() }
.collect().asList().map(List<Double>::average)
Thanks @MartinX3 , no issue, my own organization has a way to go as well in regards of official support on OSS contributions.
Just keep reporting, will care as soon as possible.