use of io.scalecube.services.transport.rsocket.RSocketServiceTransport in project scalecube by scalecube.
the class ServiceRegistryTest method test_added_removed_registration_events.
@ParameterizedTest
@MethodSource("metadataCodecSource")
public void test_added_removed_registration_events(MetadataCodec metadataCodec) {
Sinks.Many<ServiceDiscoveryEvent> events = Sinks.many().replay().all();
Microservices seed = Microservices.builder().discovery(defServiceDiscovery(metadataCodec)).transport(RSocketServiceTransport::new).startAwait();
seed.listenDiscovery().subscribe(events::tryEmitNext, events::tryEmitError, events::tryEmitComplete);
Address seedAddress = seed.discovery().address();
Microservices ms1 = Microservices.builder().discovery(defServiceDiscovery(seedAddress, metadataCodec)).transport(RSocketServiceTransport::new).services(new GreetingServiceImpl()).startAwait();
Microservices ms2 = Microservices.builder().discovery(defServiceDiscovery(seedAddress, metadataCodec)).transport(RSocketServiceTransport::new).services(new GreetingServiceImpl()).startAwait();
StepVerifier.create(events.asFlux().onBackpressureBuffer()).assertNext(event -> assertEquals(ENDPOINT_ADDED, event.type())).assertNext(event -> assertEquals(ENDPOINT_ADDED, event.type())).then(() -> Mono.whenDelayError(ms1.shutdown(), ms2.shutdown()).block(TIMEOUT)).assertNext(event -> assertEquals(ENDPOINT_LEAVING, event.type())).assertNext(event -> assertEquals(ENDPOINT_LEAVING, event.type())).assertNext(event -> assertEquals(ENDPOINT_REMOVED, event.type())).assertNext(event -> assertEquals(ENDPOINT_REMOVED, event.type())).then(() -> seed.shutdown().block(TIMEOUT)).thenCancel().verify(TIMEOUT);
}
use of io.scalecube.services.transport.rsocket.RSocketServiceTransport 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();
}
use of io.scalecube.services.transport.rsocket.RSocketServiceTransport in project scalecube by scalecube.
the class ServiceRemoteTest method test_services_contribute_to_cluster_metadata.
@Test
public void test_services_contribute_to_cluster_metadata() {
Map<String, String> tags = new HashMap<>();
tags.put("HOSTNAME", "host1");
Microservices ms = Microservices.builder().discovery(serviceEndpoint -> new ScalecubeServiceDiscovery().transport(cfg -> cfg.transportFactory(new WebsocketTransportFactory())).options(opts -> opts.metadata(serviceEndpoint))).transport(RSocketServiceTransport::new).tags(tags).services(new GreetingServiceImpl()).startAwait();
assertTrue(ms.serviceEndpoint().tags().containsKey("HOSTNAME"));
}
use of io.scalecube.services.transport.rsocket.RSocketServiceTransport 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();
}
use of io.scalecube.services.transport.rsocket.RSocketServiceTransport 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();
}
Aggregations