kptfh / feign-reactive

Reactive Feign client based on Spring WebFlux
Apache License 2.0
166 stars 159 forks source link

Support for Kotlin coroutine #21

Open emax19 opened 3 years ago

emax19 commented 3 years ago

Hi, what about writing an adapter for the kotlin coroutine compatibility?

package com.demo.feign

import kotlinx.coroutines.flow.Flow
import org.springframework.web.bind.annotation.GetMapping
import reactivefeign.spring.config.ReactiveFeignClient
import reactor.core.publisher.Flux
import reactor.core.publisher.Mono

@ReactiveFeignClient(
    name = "helloClient",
    url = "http://localhost:8080"
)
interface HelloClient {

    @GetMapping("/hello")
    fun helloMono(): Mono<String>

    @GetMapping("/hello")
    suspend fun helloKotlinMono(): String

    @GetMapping("/hello")
    fun helloFlux(): Flux<String>

    @GetMapping("/hello")
    fun helloKotlinFlux(): Flow<String>

}