Search in sources :

Example 1 with HeadersCodec

use of io.scalecube.services.transport.api.HeadersCodec 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));
}
Also used : ByteBufAllocator(io.netty.buffer.ByteBufAllocator) ReferenceCountUtil(io.scalecube.services.transport.api.ReferenceCountUtil) LoggerFactory(org.slf4j.LoggerFactory) PayloadDecoder(io.rsocket.frame.decoder.PayloadDecoder) ClientTransport(io.scalecube.services.transport.api.ClientTransport) MessageCodecException(io.scalecube.services.exceptions.MessageCodecException) ByteBuf(io.netty.buffer.ByteBuf) RSocket(io.rsocket.RSocket) Map(java.util.Map) ByteBufPayload(io.rsocket.util.ByteBufPayload) UnauthorizedException(io.scalecube.services.exceptions.UnauthorizedException) Address(io.scalecube.net.Address) ServiceReference(io.scalecube.services.ServiceReference) ServiceException(io.scalecube.services.exceptions.ServiceException) Logger(org.slf4j.Logger) MaskUtil(io.scalecube.utils.MaskUtil) RSocketConnector(io.rsocket.core.RSocketConnector) Collection(java.util.Collection) ClientChannel(io.scalecube.services.transport.api.ClientChannel) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Mono(reactor.core.publisher.Mono) ByteBufOutputStream(io.netty.buffer.ByteBufOutputStream) Payload(io.rsocket.Payload) CredentialsSupplier(io.scalecube.services.auth.CredentialsSupplier) ServiceMessageCodec(io.scalecube.services.transport.api.ServiceMessageCodec) DataCodec(io.scalecube.services.transport.api.DataCodec) Collections(java.util.Collections) HeadersCodec(io.scalecube.services.transport.api.HeadersCodec) Address(io.scalecube.net.Address) Mono(reactor.core.publisher.Mono) RSocket(io.rsocket.RSocket) ServiceMessageCodec(io.scalecube.services.transport.api.ServiceMessageCodec)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)1 ByteBufAllocator (io.netty.buffer.ByteBufAllocator)1 ByteBufOutputStream (io.netty.buffer.ByteBufOutputStream)1 Payload (io.rsocket.Payload)1 RSocket (io.rsocket.RSocket)1 RSocketConnector (io.rsocket.core.RSocketConnector)1 PayloadDecoder (io.rsocket.frame.decoder.PayloadDecoder)1 ByteBufPayload (io.rsocket.util.ByteBufPayload)1 Address (io.scalecube.net.Address)1 ServiceReference (io.scalecube.services.ServiceReference)1 CredentialsSupplier (io.scalecube.services.auth.CredentialsSupplier)1 MessageCodecException (io.scalecube.services.exceptions.MessageCodecException)1 ServiceException (io.scalecube.services.exceptions.ServiceException)1 UnauthorizedException (io.scalecube.services.exceptions.UnauthorizedException)1 ClientChannel (io.scalecube.services.transport.api.ClientChannel)1 ClientTransport (io.scalecube.services.transport.api.ClientTransport)1 DataCodec (io.scalecube.services.transport.api.DataCodec)1 HeadersCodec (io.scalecube.services.transport.api.HeadersCodec)1 ReferenceCountUtil (io.scalecube.services.transport.api.ReferenceCountUtil)1 ServiceMessageCodec (io.scalecube.services.transport.api.ServiceMessageCodec)1