Search in sources :

Example 21 with Address

use of io.scalecube.net.Address in project ignite-3 by apache.

the class ScaleCubeDirectMarshallerTransport method requestResponse.

/**
 * {@inheritDoc}
 */
@Override
public Mono<Message> requestResponse(Address address, Message request) {
    return Mono.create(sink -> {
        Objects.requireNonNull(request, "request must be not null");
        Objects.requireNonNull(request.correlationId(), "correlationId must be not null");
        Disposable receive = listen().filter(resp -> resp.correlationId() != null).filter(resp -> resp.correlationId().equals(request.correlationId())).take(1).subscribe(sink::success, sink::error, sink::success);
        Disposable send = send(address, request).subscribe(null, ex -> {
            receive.dispose();
            sink.error(ex);
        });
        sink.onDispose(Disposables.composite(send, receive));
    });
}
Also used : Disposable(reactor.core.Disposable) Disposable(reactor.core.Disposable) SocketAddress(java.net.SocketAddress) FluxSink(reactor.core.publisher.FluxSink) NetworkMessagesFactory(org.apache.ignite.internal.network.NetworkMessagesFactory) IgniteLogger(org.apache.ignite.lang.IgniteLogger) InetAddress(java.net.InetAddress) Transport(io.scalecube.cluster.transport.api.Transport) Map(java.util.Map) Message(io.scalecube.cluster.transport.api.Message) Disposables(reactor.core.Disposables) MessagingService(org.apache.ignite.network.MessagingService) Address(io.scalecube.net.Address) ConnectionManager(org.apache.ignite.internal.network.netty.ConnectionManager) DirectProcessor(reactor.core.publisher.DirectProcessor) MonoProcessor(reactor.core.publisher.MonoProcessor) NetworkMessage(org.apache.ignite.network.NetworkMessage) Mono(reactor.core.publisher.Mono) InetSocketAddress(java.net.InetSocketAddress) ClusterNode(org.apache.ignite.network.ClusterNode) NetworkAddress(org.apache.ignite.network.NetworkAddress) Objects(java.util.Objects) Nullable(org.jetbrains.annotations.Nullable) Flux(reactor.core.publisher.Flux) ScaleCubeMessageBuilder(org.apache.ignite.internal.network.message.ScaleCubeMessageBuilder) IgniteInternalException(org.apache.ignite.lang.IgniteInternalException) ScaleCubeMessage(org.apache.ignite.internal.network.message.ScaleCubeMessage) NetworkMessageTypes(org.apache.ignite.internal.network.NetworkMessageTypes)

Aggregations

Address (io.scalecube.net.Address)21 ScalecubeServiceDiscovery (io.scalecube.services.discovery.ScalecubeServiceDiscovery)17 WebsocketTransportFactory (io.scalecube.transport.netty.websocket.WebsocketTransportFactory)17 Mono (reactor.core.publisher.Mono)17 RSocketServiceTransport (io.scalecube.services.transport.rsocket.RSocketServiceTransport)15 Microservices (io.scalecube.services.Microservices)12 ServiceMessage (io.scalecube.services.api.ServiceMessage)7 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)7 ServiceDiscoveryEvent (io.scalecube.services.discovery.api.ServiceDiscoveryEvent)6 List (java.util.List)6 ServiceDiscoveryFactory (io.scalecube.services.discovery.api.ServiceDiscoveryFactory)5 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)5 Sinks (reactor.core.publisher.Sinks)5 Duration (java.time.Duration)4 Collections (java.util.Collections)4 Map (java.util.Map)4 Optional (java.util.Optional)4 Flux (reactor.core.publisher.Flux)4 ServiceCall (io.scalecube.services.ServiceCall)3 ServiceInfo (io.scalecube.services.ServiceInfo)3