use of io.scalecube.services.transport.api.ServiceMessageCodec in project scalecube by scalecube.
the class RSocketClientTransport method create.
@Override
public ClientChannel create(ServiceReference serviceReference) {
// keep reference for threadsafety
final Map<Address, Mono<RSocket>> monoMap = rsockets.get();
final Address address = serviceReference.address();
Mono<RSocket> mono = monoMap.computeIfAbsent(address, key -> getCredentials(serviceReference).flatMap(creds -> connect(key, creds, monoMap)).cache().doOnError(ex -> monoMap.remove(key)));
return new RSocketClientChannel(mono, new ServiceMessageCodec(headersCodec, dataCodecs));
}
use of io.scalecube.services.transport.api.ServiceMessageCodec in project scalecube by scalecube.
the class StreamingServiceTest method setup.
@BeforeAll
public static void setup() {
gateway = Microservices.builder().discovery(serviceEndpoint -> new ScalecubeServiceDiscovery().transport(cfg -> cfg.transportFactory(new WebsocketTransportFactory())).options(opts -> opts.metadata(serviceEndpoint))).transport(RSocketServiceTransport::new).defaultDataDecoder(ServiceMessageCodec::decodeData).startAwait();
final Address gatewayAddress = gateway.discovery().address();
node = Microservices.builder().discovery(endpoint -> new ScalecubeServiceDiscovery().transport(cfg -> cfg.transportFactory(new WebsocketTransportFactory())).options(opts -> opts.metadata(endpoint)).membership(cfg -> cfg.seedMembers(gatewayAddress))).transport(RSocketServiceTransport::new).defaultDataDecoder(ServiceMessageCodec::decodeData).services(new SimpleQuoteService()).startAwait();
}
Aggregations