Search in sources :

Example 1 with CoarseGrainedService

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

the class ServiceRemoteTest method test_remote_serviceA_calls_serviceB_with_dispatcher.

@Test
public void test_remote_serviceA_calls_serviceB_with_dispatcher() {
    // getting proxy from any node at any given time.
    CoarseGrainedServiceImpl another = new CoarseGrainedServiceImpl();
    // Create microservices instance cluster.
    Microservices provider = Microservices.builder().discovery(ServiceRemoteTest::serviceDiscovery).transport(RSocketServiceTransport::new).services(// add service a and b
    another).startAwait();
    // Get a proxy to the service api.
    CoarseGrainedService service = gateway.call().api(CoarseGrainedService.class);
    String response = service.callGreetingWithDispatcher("joe").block(Duration.ofSeconds(5));
    assertEquals(response, " hello to: joe");
    provider.shutdown().then(Mono.delay(TIMEOUT2)).block();
}
Also used : CoarseGrainedServiceImpl(io.scalecube.services.sut.CoarseGrainedServiceImpl) RSocketServiceTransport(io.scalecube.services.transport.rsocket.RSocketServiceTransport) CoarseGrainedService(io.scalecube.services.sut.CoarseGrainedService) Test(org.junit.jupiter.api.Test)

Example 2 with CoarseGrainedService

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

the class ServiceRemoteTest method test_remote_serviceA_calls_serviceB_using_setter.

@Test
public void test_remote_serviceA_calls_serviceB_using_setter() {
    // Create microservices instance cluster.
    // noinspection unused
    Microservices provider = Microservices.builder().discovery(ServiceRemoteTest::serviceDiscovery).transport(RSocketServiceTransport::new).services(// add service a and b
    new CoarseGrainedServiceImpl()).startAwait();
    // Get a proxy to the service api.
    CoarseGrainedService service = gateway.call().api(CoarseGrainedService.class);
    Publisher<String> future = service.callGreeting("joe");
    assertEquals(" hello to: joe", Mono.from(future).block(Duration.ofSeconds(1)));
    provider.shutdown().then(Mono.delay(TIMEOUT2)).block();
}
Also used : CoarseGrainedServiceImpl(io.scalecube.services.sut.CoarseGrainedServiceImpl) RSocketServiceTransport(io.scalecube.services.transport.rsocket.RSocketServiceTransport) CoarseGrainedService(io.scalecube.services.sut.CoarseGrainedService) Test(org.junit.jupiter.api.Test)

Example 3 with CoarseGrainedService

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

the class ServiceRemoteTest method test_remote_serviceA_calls_serviceB.

@Test
public void test_remote_serviceA_calls_serviceB() {
    // getting proxy from any node at any given time.
    CoarseGrainedServiceImpl another = new CoarseGrainedServiceImpl();
    // Create microservices instance cluster.
    // noinspection unused
    Microservices provider = Microservices.builder().discovery(ServiceRemoteTest::serviceDiscovery).transport(RSocketServiceTransport::new).services(another).startAwait();
    // Get a proxy to the service api.
    CoarseGrainedService service = gateway.call().api(CoarseGrainedService.class);
    Publisher<String> future = service.callGreeting("joe");
    assertEquals(" hello to: joe", Mono.from(future).block(Duration.ofSeconds(1)));
    provider.shutdown().then(Mono.delay(TIMEOUT2)).block();
}
Also used : CoarseGrainedServiceImpl(io.scalecube.services.sut.CoarseGrainedServiceImpl) RSocketServiceTransport(io.scalecube.services.transport.rsocket.RSocketServiceTransport) CoarseGrainedService(io.scalecube.services.sut.CoarseGrainedService) Test(org.junit.jupiter.api.Test)

Example 4 with CoarseGrainedService

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

the class ServiceRemoteTest method test_remote_serviceA_calls_serviceB_with_timeout.

@Test
public void test_remote_serviceA_calls_serviceB_with_timeout() {
    // getting proxy from any node at any given time.
    CoarseGrainedServiceImpl another = new CoarseGrainedServiceImpl();
    // Create microservices instance cluster.
    Microservices ms = Microservices.builder().discovery(ServiceRemoteTest::serviceDiscovery).transport(RSocketServiceTransport::new).services(// add service a and b
    another).startAwait();
    // Get a proxy to the service api.
    CoarseGrainedService service = gateway.call().api(CoarseGrainedService.class);
    InternalServiceException exception = assertThrows(InternalServiceException.class, () -> Mono.from(service.callGreetingTimeout("joe")).block());
    assertTrue(exception.getMessage().contains("Did not observe any item or terminal signal"));
    System.out.println("done");
    ms.shutdown().then(Mono.delay(TIMEOUT2)).block();
}
Also used : CoarseGrainedServiceImpl(io.scalecube.services.sut.CoarseGrainedServiceImpl) RSocketServiceTransport(io.scalecube.services.transport.rsocket.RSocketServiceTransport) CoarseGrainedService(io.scalecube.services.sut.CoarseGrainedService) InternalServiceException(io.scalecube.services.exceptions.InternalServiceException) Test(org.junit.jupiter.api.Test)

Aggregations

CoarseGrainedService (io.scalecube.services.sut.CoarseGrainedService)4 CoarseGrainedServiceImpl (io.scalecube.services.sut.CoarseGrainedServiceImpl)4 RSocketServiceTransport (io.scalecube.services.transport.rsocket.RSocketServiceTransport)4 Test (org.junit.jupiter.api.Test)4 InternalServiceException (io.scalecube.services.exceptions.InternalServiceException)1