Search in sources :

Example 1 with SimpleQuoteService

use of io.scalecube.services.sut.SimpleQuoteService in project scalecube by scalecube.

the class ServiceCallRemoteTest method test_service_address_lookup_occur_only_after_subscription.

@Test
public void test_service_address_lookup_occur_only_after_subscription() {
    Flux<ServiceMessage> quotes = gateway.call().requestMany(ServiceMessage.builder().qualifier(QuoteService.NAME, "onlyOneAndThenNever").data(null).build());
    // Add service to cluster AFTER creating a call object.
    // (prove address lookup occur only after subscription)
    Microservices quotesService = serviceProvider(new SimpleQuoteService());
    StepVerifier.create(quotes.take(1)).expectNextCount(1).expectComplete().verify(TIMEOUT);
    try {
        quotesService.shutdown();
    } catch (Exception ignored) {
    // no-op
    }
}
Also used : ServiceMessage(io.scalecube.services.api.ServiceMessage) SimpleQuoteService(io.scalecube.services.sut.SimpleQuoteService) ServiceException(io.scalecube.services.exceptions.ServiceException) Test(org.junit.jupiter.api.Test)

Example 2 with SimpleQuoteService

use of io.scalecube.services.sut.SimpleQuoteService 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();
}
Also used : Assertions.fail(org.junit.jupiter.api.Assertions.fail) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) ScalecubeServiceDiscovery(io.scalecube.services.discovery.ScalecubeServiceDiscovery) Disposable(reactor.core.Disposable) SimpleQuoteService(io.scalecube.services.sut.SimpleQuoteService) RSocketServiceTransport(io.scalecube.services.transport.rsocket.RSocketServiceTransport) TimeUnit(java.util.concurrent.TimeUnit) Test(org.junit.jupiter.api.Test) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) ServiceMessageCodec(io.scalecube.services.transport.api.ServiceMessageCodec) BeforeAll(org.junit.jupiter.api.BeforeAll) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Duration(java.time.Duration) QuoteService(io.scalecube.services.sut.QuoteService) WebsocketTransportFactory(io.scalecube.transport.netty.websocket.WebsocketTransportFactory) ServiceMessage(io.scalecube.services.api.ServiceMessage) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Address(io.scalecube.net.Address) ScalecubeServiceDiscovery(io.scalecube.services.discovery.ScalecubeServiceDiscovery) Address(io.scalecube.net.Address) WebsocketTransportFactory(io.scalecube.transport.netty.websocket.WebsocketTransportFactory) SimpleQuoteService(io.scalecube.services.sut.SimpleQuoteService) ServiceMessageCodec(io.scalecube.services.transport.api.ServiceMessageCodec) RSocketServiceTransport(io.scalecube.services.transport.rsocket.RSocketServiceTransport) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 3 with SimpleQuoteService

use of io.scalecube.services.sut.SimpleQuoteService in project scalecube by scalecube.

the class RSocketServiceTransportTest method setUp.

@BeforeEach
public void setUp() {
    gateway = Microservices.builder().discovery(endpoint -> new ScalecubeServiceDiscovery().transport(cfg -> cfg.transportFactory(new WebsocketTransportFactory())).options(opts -> opts.metadata(endpoint))).transport(RSocketServiceTransport::new).startAwait();
    final Address gatewayAddress = this.gateway.discovery().address();
    serviceNode = Microservices.builder().discovery(serviceEndpoint -> new ScalecubeServiceDiscovery().transport(cfg -> cfg.transportFactory(new WebsocketTransportFactory())).options(opts -> opts.metadata(serviceEndpoint)).membership(cfg -> cfg.seedMembers(gatewayAddress))).transport(RSocketServiceTransport::new).services(new SimpleQuoteService()).startAwait();
}
Also used : ScalecubeServiceDiscovery(io.scalecube.services.discovery.ScalecubeServiceDiscovery) BeforeEach(org.junit.jupiter.api.BeforeEach) Disposable(reactor.core.Disposable) Mono(reactor.core.publisher.Mono) ConnectionClosedException(io.scalecube.services.exceptions.ConnectionClosedException) AtomicReference(java.util.concurrent.atomic.AtomicReference) SimpleQuoteService(io.scalecube.services.sut.SimpleQuoteService) TimeUnit(java.util.concurrent.TimeUnit) Test(org.junit.jupiter.api.Test) CountDownLatch(java.util.concurrent.CountDownLatch) AfterEach(org.junit.jupiter.api.AfterEach) Microservices(io.scalecube.services.Microservices) ServiceCall(io.scalecube.services.ServiceCall) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Duration(java.time.Duration) QuoteService(io.scalecube.services.sut.QuoteService) ServiceDiscoveryEvent(io.scalecube.services.discovery.api.ServiceDiscoveryEvent) WebsocketTransportFactory(io.scalecube.transport.netty.websocket.WebsocketTransportFactory) Optional(java.util.Optional) ServiceMessage(io.scalecube.services.api.ServiceMessage) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Address(io.scalecube.net.Address) BaseTest(io.scalecube.services.BaseTest) ScalecubeServiceDiscovery(io.scalecube.services.discovery.ScalecubeServiceDiscovery) Address(io.scalecube.net.Address) WebsocketTransportFactory(io.scalecube.transport.netty.websocket.WebsocketTransportFactory) SimpleQuoteService(io.scalecube.services.sut.SimpleQuoteService) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

ServiceMessage (io.scalecube.services.api.ServiceMessage)3 SimpleQuoteService (io.scalecube.services.sut.SimpleQuoteService)3 Test (org.junit.jupiter.api.Test)3 Address (io.scalecube.net.Address)2 ScalecubeServiceDiscovery (io.scalecube.services.discovery.ScalecubeServiceDiscovery)2 QuoteService (io.scalecube.services.sut.QuoteService)2 WebsocketTransportFactory (io.scalecube.transport.netty.websocket.WebsocketTransportFactory)2 Duration (java.time.Duration)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 TimeUnit (java.util.concurrent.TimeUnit)2 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)2 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)2 Disposable (reactor.core.Disposable)2 BaseTest (io.scalecube.services.BaseTest)1 Microservices (io.scalecube.services.Microservices)1 ServiceCall (io.scalecube.services.ServiceCall)1 ServiceDiscoveryEvent (io.scalecube.services.discovery.api.ServiceDiscoveryEvent)1 ConnectionClosedException (io.scalecube.services.exceptions.ConnectionClosedException)1 ServiceException (io.scalecube.services.exceptions.ServiceException)1 ServiceMessageCodec (io.scalecube.services.transport.api.ServiceMessageCodec)1