rsocket-broker / rsocket-broker-client

Apache License 2.0
33 stars 8 forks source link

Initial RoutingRSocketConnector implementation #10

Closed spencergibb closed 4 years ago

spencergibb commented 4 years ago

Simple usage looks like (RoutingRSocketClient is of course optional).

RoutingRSocketClient client = RoutingRSocketConnector.create()
        .routeId(id)
        .serviceName("ping")
        .toRSocketClient(TcpClientTransport.create(port));

client.requestChannel(Flux.interval(Duration.ofSeconds(1)).map(i -> {
        ByteBuf data = ...
        ByteBuf routingMetadata = client.address("pong");
        // or ByteBuf routingMetadata = client.address(tags ->                      logger.debug("Sending ping" + id);
        return DefaultPayload.create(data, routingMetadata);
});
OlegDokuka commented 4 years ago

In general LGTM. However, I would add a Route interface as we discussed that previously and than make make RoutingRSocketClient implements RSocketClient, Route and then RoutingRSocket implements RSocket, Route.

WDYT, @spencergibb?

spencergibb commented 4 years ago

Remind me what Route looks like

OlegDokuka commented 4 years ago

@spencergibb Guess it should be a simple interface like the following:


interface Router {
  void encodeAddressMetadata(CompositeByteBuf metadataHolder, Consumer<Tags.Builder> tagsConsumer)
}
spencergibb commented 4 years ago

Oh, right. Yes. I'll do that.

spencergibb commented 4 years ago

I missed this part.

and then RoutingRSocket implements RSocket, Route.

Are you suggesting I wrap RSocket that also implements Route? If so, I can do a follow up for that and any other edits.