Skip to content

RSocketGraphQlClient.Builder requires either tcp or websocket #497

Closed as not planned
@iromu

Description

@iromu

Description

Expected to work like plain RSocketRequester, with offers the following options to configure the transport:

  • tcp
  • websocket
  • transports (with load balancing option)

RSocketGraphQlClient.Builder only accepts:

  • tcp
  • websocket
  • clientTransport

Otherwise, it throws an error "Neither WebSocket nor TCP networking configured"

RSocketGraphQlClient.Builder.rsocketRequester is ignored.

Example code

RSocketRequester

Configuration

.transports() creates a LoadbalanceRSocketClient client

@Bean
public RSocketRequester rSocketRequesterLb(RSocketRequester.Builder rsocketRequesterBuilder,
                                           RSocketStrategies strategies,
                                           ReactiveDiscoveryClient discoveryClient) {
    Flux<List<LoadbalanceTarget>> servers = getServers(discoveryClient);

    return rsocketRequesterBuilder
        .rsocketStrategies(strategies)
        .dataMimeType(DEFAULT_PRIVATE_REST_MIMETYPE)
        .transports(servers, new RoundRobinLoadbalanceStrategy());
}

Client

rSocketRequester
            .route("the rsocket messaging route")
            .data(Request.builder()
                .market(market)
                .currencyPair(currencyPair)
                .after(after).sortField("timestamp")
                .sortDirection(Sort.Direction.ASC.name())
                .projection("BarProjection")
                .build())
            .retrieveFlux(CandleModel.class)

RSocketGraphQlClient.Builder

Configuration

@Bean
public RSocketGraphQlClient rSocketGraphQlClient(RSocketGraphQlClient.Builder<?> builder,
                                                 RSocketStrategies strategies,
                                                 ReactiveDiscoveryClient discoveryClient
) {
    return builder
        .rsocketRequester(b -> {
            Flux<List<LoadbalanceTarget>> servers = getServers(discoveryClient);
            b.rsocketStrategies(strategies)
                .dataMimeType(DEFAULT_PRIVATE_REST_MIMETYPE)
                // LB will be ignored : (
                .transports(servers, new RoundRobinLoadbalanceStrategy());
        })
        // "Hardcoded" hostname and port
        .tcp(hostRsocket, portRsocket)
        .route("graphql")
        .build();
}

Client

        return rSocketGraphQlClient.documentName("candlesAfterTimestamp")
            .variable("market", market)
            .variable("currencyPair", currencyPair)
            .variable("granularity", granularity.getInterval())
            .variable("timestamp", after)
            .retrieveSubscription("candlesAfterTimestamp")
            .toEntity(CandleModel.class)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions