Search in sources :

Example 16 with WebsocketTransportFactory

use of io.scalecube.transport.netty.websocket.WebsocketTransportFactory 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();
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) ScalecubeServiceDiscovery(io.scalecube.services.discovery.ScalecubeServiceDiscovery) StepVerifier(reactor.test.StepVerifier) InternalServiceException(io.scalecube.services.exceptions.InternalServiceException) Publisher(org.reactivestreams.Publisher) GreetingResponse(io.scalecube.services.sut.GreetingResponse) RSocketServiceTransport(io.scalecube.services.transport.rsocket.RSocketServiceTransport) AfterAll(org.junit.jupiter.api.AfterAll) Test(org.junit.jupiter.api.Test) ForbiddenException(io.scalecube.services.exceptions.ForbiddenException) ServiceUnavailableException(io.scalecube.services.exceptions.ServiceUnavailableException) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) BeforeAll(org.junit.jupiter.api.BeforeAll) Mono.from(reactor.core.publisher.Mono.from) GreetingServiceImpl(io.scalecube.services.sut.GreetingServiceImpl) WebsocketTransportFactory(io.scalecube.transport.netty.websocket.WebsocketTransportFactory) ServiceMessage(io.scalecube.services.api.ServiceMessage) BadRequestException(io.scalecube.services.exceptions.BadRequestException) Address(io.scalecube.net.Address) ScalecubeServiceDiscovery(io.scalecube.services.discovery.ScalecubeServiceDiscovery) Address(io.scalecube.net.Address) WebsocketTransportFactory(io.scalecube.transport.netty.websocket.WebsocketTransportFactory) GreetingServiceImpl(io.scalecube.services.sut.GreetingServiceImpl) RSocketServiceTransport(io.scalecube.services.transport.rsocket.RSocketServiceTransport) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 17 with WebsocketTransportFactory

use of io.scalecube.transport.netty.websocket.WebsocketTransportFactory 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 18 with WebsocketTransportFactory

use of io.scalecube.transport.netty.websocket.WebsocketTransportFactory 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"));
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) Sinks(reactor.core.publisher.Sinks) StepVerifier(reactor.test.StepVerifier) CoarseGrainedServiceImpl(io.scalecube.services.sut.CoarseGrainedServiceImpl) TimeoutException(java.util.concurrent.TimeoutException) Hooks(reactor.core.publisher.Hooks) GreetingResponse(io.scalecube.services.sut.GreetingResponse) HashMap(java.util.HashMap) Disabled(org.junit.jupiter.api.Disabled) AfterAll(org.junit.jupiter.api.AfterAll) BeforeAll(org.junit.jupiter.api.BeforeAll) CoarseGrainedService(io.scalecube.services.sut.CoarseGrainedService) Duration(java.time.Duration) Map(java.util.Map) WebsocketTransportFactory(io.scalecube.transport.netty.websocket.WebsocketTransportFactory) GreetingRequest(io.scalecube.services.sut.GreetingRequest) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Address(io.scalecube.net.Address) ScalecubeServiceDiscovery(io.scalecube.services.discovery.ScalecubeServiceDiscovery) EmptyGreetingResponse(io.scalecube.services.sut.EmptyGreetingResponse) InternalServiceException(io.scalecube.services.exceptions.InternalServiceException) Publisher(org.reactivestreams.Publisher) Mono(reactor.core.publisher.Mono) ServiceDiscovery(io.scalecube.services.discovery.api.ServiceDiscovery) RSocketServiceTransport(io.scalecube.services.transport.rsocket.RSocketServiceTransport) Test(org.junit.jupiter.api.Test) Flux(reactor.core.publisher.Flux) FAIL_FAST(reactor.core.publisher.Sinks.EmitFailureHandler.FAIL_FAST) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) GreetingService(io.scalecube.services.sut.GreetingService) EmptyGreetingRequest(io.scalecube.services.sut.EmptyGreetingRequest) GreetingServiceImpl(io.scalecube.services.sut.GreetingServiceImpl) ServiceMessage(io.scalecube.services.api.ServiceMessage) ScalecubeServiceDiscovery(io.scalecube.services.discovery.ScalecubeServiceDiscovery) HashMap(java.util.HashMap) WebsocketTransportFactory(io.scalecube.transport.netty.websocket.WebsocketTransportFactory) GreetingServiceImpl(io.scalecube.services.sut.GreetingServiceImpl) Test(org.junit.jupiter.api.Test)

Example 19 with WebsocketTransportFactory

use of io.scalecube.transport.netty.websocket.WebsocketTransportFactory 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

ScalecubeServiceDiscovery (io.scalecube.services.discovery.ScalecubeServiceDiscovery)19 WebsocketTransportFactory (io.scalecube.transport.netty.websocket.WebsocketTransportFactory)19 RSocketServiceTransport (io.scalecube.services.transport.rsocket.RSocketServiceTransport)17 Address (io.scalecube.net.Address)15 Microservices (io.scalecube.services.Microservices)15 Mono (reactor.core.publisher.Mono)15 Duration (java.time.Duration)8 ServiceMessage (io.scalecube.services.api.ServiceMessage)7 Test (org.junit.jupiter.api.Test)7 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)6 ServiceInfo (io.scalecube.services.ServiceInfo)5 ServiceCall (io.scalecube.services.ServiceCall)4 Authenticator (io.scalecube.services.auth.Authenticator)4 UnauthorizedException (io.scalecube.services.exceptions.UnauthorizedException)4 BeforeAll (org.junit.jupiter.api.BeforeAll)4 BaseTest (io.scalecube.services.BaseTest)3 ServiceEndpoint (io.scalecube.services.ServiceEndpoint)3 CredentialsSupplier (io.scalecube.services.auth.CredentialsSupplier)3 GreetingServiceImpl (io.scalecube.services.examples.helloworld.service.GreetingServiceImpl)3 HashMap (java.util.HashMap)3