Search in sources :

Example 11 with GSVRoutingMetadata

use of org.kin.rsocket.core.metadata.GSVRoutingMetadata in project kin-rsocket-broker by huangjianqin.

the class BrokerRequestHandler method requestChannel.

private Flux<Payload> requestChannel(Payload signal, Publisher<Payload> payloads) {
    BinaryRoutingMetadata binaryRoutingMetadata = BinaryRoutingMetadata.extract(signal.metadata());
    GSVRoutingMetadata gsvRoutingMetadata;
    if (binaryRoutingMetadata != null) {
        gsvRoutingMetadata = binaryRoutingMetadata.toGSVRoutingMetadata();
    } else {
        RSocketCompositeMetadata compositeMetadata = RSocketCompositeMetadata.of(signal.metadata());
        gsvRoutingMetadata = compositeMetadata.getMetadata(RSocketMimeType.ROUTING);
        if (gsvRoutingMetadata == null) {
            return Flux.error(new InvalidException("No Routing metadata"));
        }
    }
    Mono<RSocket> destination = findDestination(gsvRoutingMetadata);
    return destination.flatMapMany(rsocket -> {
        MetricsUtils.metrics(gsvRoutingMetadata, FrameType.REQUEST_CHANNEL.name());
        return rsocket.requestChannel(payloads);
    });
}
Also used : RSocketCompositeMetadata(org.kin.rsocket.core.metadata.RSocketCompositeMetadata) GSVRoutingMetadata(org.kin.rsocket.core.metadata.GSVRoutingMetadata) BinaryRoutingMetadata(org.kin.rsocket.core.metadata.BinaryRoutingMetadata) InvalidException(io.rsocket.exceptions.InvalidException) RSocket(io.rsocket.RSocket) AbstractRSocket(org.kin.rsocket.core.AbstractRSocket)

Aggregations

GSVRoutingMetadata (org.kin.rsocket.core.metadata.GSVRoutingMetadata)11 InvalidException (io.rsocket.exceptions.InvalidException)7 RSocketCompositeMetadata (org.kin.rsocket.core.metadata.RSocketCompositeMetadata)7 Payload (io.rsocket.Payload)4 RSocket (io.rsocket.RSocket)4 ByteBufPayload (io.rsocket.util.ByteBufPayload)4 AbstractRSocket (org.kin.rsocket.core.AbstractRSocket)4 BinaryRoutingMetadata (org.kin.rsocket.core.metadata.BinaryRoutingMetadata)4 ByteBuf (io.netty.buffer.ByteBuf)3 ReferenceCountUtil (io.netty.util.ReferenceCountUtil)3 Nonnull (javax.annotation.Nonnull)3 LoggerOprs (org.kin.framework.log.LoggerOprs)3 ExceptionUtils (org.kin.framework.utils.ExceptionUtils)3 Codecs (org.kin.rsocket.core.codec.Codecs)3 MessageAcceptMimeTypesMetadata (org.kin.rsocket.core.metadata.MessageAcceptMimeTypesMetadata)3 MessageMimeTypeMetadata (org.kin.rsocket.core.metadata.MessageMimeTypeMetadata)3 Flux (reactor.core.publisher.Flux)3 Mono (reactor.core.publisher.Mono)3 RSocketEndpoint (org.kin.rsocket.broker.RSocketEndpoint)2 RSocketAppPrincipal (org.kin.rsocket.auth.RSocketAppPrincipal)1