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);
});
}
Aggregations