Reactive FunctionClients

@FunctionClient interfaces support RxJava constructs, so the above interfaces could be implemented as shown below:

RxMathClient

  1. import io.micronaut.runtime.server.EmbeddedServer;
  2. import io.micronaut.function.client.FunctionClient;
  3. import org.junit.Test;
  4. import javax.inject.Named;
  5. import static org.junit.Assert.assertEquals;
  6. import io.reactivex.Single;
  7. import java.util.Collections;
  8. @FunctionClient
  9. interface RxMathClient {
  10. Single<Long> max();
  11. @Named("round")
  12. Single<Integer> rnd(float value);
  13. Single<Long> sum(Sum sum);
  14. }

RxMathClient

  1. import io.micronaut.function.client.FunctionClient
  2. import javax.inject.Named
  3. import io.reactivex.Single
  4. @FunctionClient
  5. static interface RxMathClient {
  6. Single<Long> max()
  7. @Named("round")
  8. Single<Integer> rnd(float value)
  9. Single<Long> sum(Sum sum)
  10. }

RxMathClient

  1. import io.kotlintest.shouldBe
  2. import io.kotlintest.specs.StringSpec
  3. import io.micronaut.context.ApplicationContext
  4. import io.micronaut.runtime.server.EmbeddedServer
  5. import io.micronaut.function.client.FunctionClient
  6. import io.micronaut.http.client.RxHttpClient
  7. import javax.inject.Named
  8. import io.reactivex.Single
  9. @FunctionClient
  10. internal interface RxMathClient {
  11. fun max(): Single<Long>
  12. @Named("round")
  13. fun rnd(value: Float): Single<Int>
  14. fun sum(sum: Sum): Single<Long>
  15. }