use of io.scalecube.net.Address in project scalecube by scalecube.
the class ErrorFlowTest method initNodes.
@BeforeAll
public static void initNodes() {
provider = Microservices.builder().discovery(endpoint -> new ScalecubeServiceDiscovery().transport(cfg -> cfg.transportFactory(new WebsocketTransportFactory())).transport(cfg -> cfg.port(PORT.incrementAndGet())).options(opts -> opts.metadata(endpoint))).transport(RSocketServiceTransport::new).services(new GreetingServiceImpl()).startAwait();
final Address seedAddress = provider.discovery().address();
consumer = Microservices.builder().discovery(endpoint -> new ScalecubeServiceDiscovery().membership(cfg -> cfg.seedMembers(seedAddress)).transport(cfg -> cfg.transportFactory(new WebsocketTransportFactory())).transport(cfg -> cfg.port(PORT.incrementAndGet())).options(opts -> opts.metadata(endpoint))).transport(RSocketServiceTransport::new).startAwait();
}
use of io.scalecube.net.Address in project scalecube by scalecube.
the class ServiceRegistryTest method test_delayed_listen_to_discovery_events.
@ParameterizedTest
@MethodSource("metadataCodecSource")
public void test_delayed_listen_to_discovery_events(MetadataCodec metadataCodec) {
Sinks.Many<ServiceDiscoveryEvent> processor = Sinks.many().replay().all();
List<Microservices> cluster = new CopyOnWriteArrayList<>();
Microservices seed = Microservices.builder().discovery(defServiceDiscovery(metadataCodec)).transport(RSocketServiceTransport::new).services(new GreetingServiceImpl()).startAwait();
cluster.add(seed);
seed.listenDiscovery().subscribe(processor::tryEmitNext, processor::tryEmitError, processor::tryEmitComplete);
Address seedAddress = seed.discovery().address();
StepVerifier.create(processor.asFlux().onBackpressureBuffer()).then(() -> {
Microservices ms1 = Microservices.builder().discovery(defServiceDiscovery(seedAddress, metadataCodec)).transport(RSocketServiceTransport::new).services(new GreetingServiceImpl(), new AnnotationServiceImpl()).startAwait();
cluster.add(ms1);
}).assertNext(event -> assertEquals(ENDPOINT_ADDED, event.type())).then(() -> {
Microservices ms2 = Microservices.builder().discovery(defServiceDiscovery(seedAddress, metadataCodec)).transport(RSocketServiceTransport::new).services(new GreetingServiceImpl()).startAwait();
cluster.add(ms2);
}).assertNext(event -> assertEquals(ENDPOINT_ADDED, event.type())).thenCancel().verify(TIMEOUT);
StepVerifier.create(seed.call().api(AnnotationService.class).serviceDiscoveryEventTypes()).assertNext(type -> assertEquals(ENDPOINT_ADDED, type)).assertNext(type -> assertEquals(ENDPOINT_ADDED, type)).thenCancel().verify(TIMEOUT);
Mono.whenDelayError(cluster.stream().map(Microservices::shutdown).toArray(Mono[]::new)).block(TIMEOUT);
}
use of io.scalecube.net.Address 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.net.Address 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.net.Address 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();
}
Aggregations