All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.scalecube.services.gateway.transport.GatewayClientChannel Maven / Gradle / Ivy

package io.scalecube.services.gateway.transport;

import io.scalecube.services.api.ServiceMessage;
import io.scalecube.services.transport.api.ClientChannel;
import io.scalecube.services.transport.api.ServiceMessageCodec;
import java.lang.reflect.Type;
import org.reactivestreams.Publisher;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

public class GatewayClientChannel implements ClientChannel {

  private final GatewayClient gatewayClient;

  GatewayClientChannel(GatewayClient gatewayClient) {
    this.gatewayClient = gatewayClient;
  }

  @Override
  public Mono requestResponse(ServiceMessage clientMessage, Type responseType) {
    return gatewayClient
        .requestResponse(clientMessage)
        .map(msg -> ServiceMessageCodec.decodeData(msg, responseType));
  }

  @Override
  public Flux requestStream(ServiceMessage clientMessage, Type responseType) {
    return gatewayClient
        .requestStream(clientMessage)
        .map(msg -> ServiceMessageCodec.decodeData(msg, responseType));
  }

  @Override
  public Flux requestChannel(
      Publisher clientMessageStream, Type responseType) {
    return gatewayClient
        .requestChannel(Flux.from(clientMessageStream))
        .map(msg -> ServiceMessageCodec.decodeData(msg, responseType));
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy