Search in sources :

Example 1 with TagService

use of io.scalecube.services.routings.sut.TagService in project scalecube by scalecube.

the class RoutersTest 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).startAwait();
    gatewayAddress = gateway.discovery().address();
    // Create microservices instance cluster.
    provider1 = 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).services(ServiceInfo.fromServiceInstance(new GreetingServiceImpl(1)).tag("ONLYFOR", "joe").tag("SENDER", "1").build(), ServiceInfo.fromServiceInstance(new GreetingServiceImplA()).tag("Weight", "0.1").build()).startAwait();
    // Create microservices instance cluster.
    provider2 = 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).services(ServiceInfo.fromServiceInstance(new GreetingServiceImpl(2)).tag("ONLYFOR", "fransin").tag("SENDER", "2").build(), ServiceInfo.fromServiceInstance(new GreetingServiceImplB()).tag("Weight", "0.9").build()).startAwait();
    TagService tagService = input -> input.map(String::toUpperCase);
    provider3 = 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).services(ServiceInfo.fromServiceInstance(tagService).tag("tagB", "bb").tag("tagC", "c").build()).startAwait();
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) GreetingServiceImplB(io.scalecube.services.routings.sut.GreetingServiceImplB) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) GreetingServiceImplA(io.scalecube.services.routings.sut.GreetingServiceImplA) DummyRouter(io.scalecube.services.routings.sut.DummyRouter) Assertions.assertNotEquals(org.junit.jupiter.api.Assertions.assertNotEquals) GreetingResponse(io.scalecube.services.sut.GreetingResponse) HashSet(java.util.HashSet) AfterAll(org.junit.jupiter.api.AfterAll) RandomServiceRouter(io.scalecube.services.routing.RandomServiceRouter) GREETING_REQUEST_REQ2(io.scalecube.services.TestRequests.GREETING_REQUEST_REQ2) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) BeforeAll(org.junit.jupiter.api.BeforeAll) Arrays.asList(java.util.Arrays.asList) ServiceCall(io.scalecube.services.ServiceCall) 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) ServiceReference(io.scalecube.services.ServiceReference) ScalecubeServiceDiscovery(io.scalecube.services.discovery.ScalecubeServiceDiscovery) CanaryService(io.scalecube.services.routings.sut.CanaryService) ServiceInfo(io.scalecube.services.ServiceInfo) Mono(reactor.core.publisher.Mono) TagService(io.scalecube.services.routings.sut.TagService) RSocketServiceTransport(io.scalecube.services.transport.rsocket.RSocketServiceTransport) TimeUnit(java.util.concurrent.TimeUnit) Test(org.junit.jupiter.api.Test) Routers(io.scalecube.services.routing.Routers) Flux(reactor.core.publisher.Flux) Microservices(io.scalecube.services.Microservices) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Reflect(io.scalecube.services.Reflect) GREETING_REQUEST_REQ(io.scalecube.services.TestRequests.GREETING_REQUEST_REQ) GreetingServiceImpl(io.scalecube.services.sut.GreetingServiceImpl) Optional(java.util.Optional) ServiceMessage(io.scalecube.services.api.ServiceMessage) BaseTest(io.scalecube.services.BaseTest) WeightedRandomRouter(io.scalecube.services.routings.sut.WeightedRandomRouter) ScalecubeServiceDiscovery(io.scalecube.services.discovery.ScalecubeServiceDiscovery) WebsocketTransportFactory(io.scalecube.transport.netty.websocket.WebsocketTransportFactory) TagService(io.scalecube.services.routings.sut.TagService) GreetingServiceImpl(io.scalecube.services.sut.GreetingServiceImpl) RSocketServiceTransport(io.scalecube.services.transport.rsocket.RSocketServiceTransport) GreetingServiceImplA(io.scalecube.services.routings.sut.GreetingServiceImplA) GreetingServiceImplB(io.scalecube.services.routings.sut.GreetingServiceImplB) BeforeAll(org.junit.jupiter.api.BeforeAll)

Aggregations

Address (io.scalecube.net.Address)1 BaseTest (io.scalecube.services.BaseTest)1 Microservices (io.scalecube.services.Microservices)1 Reflect (io.scalecube.services.Reflect)1 ServiceCall (io.scalecube.services.ServiceCall)1 ServiceInfo (io.scalecube.services.ServiceInfo)1 ServiceReference (io.scalecube.services.ServiceReference)1 GREETING_REQUEST_REQ (io.scalecube.services.TestRequests.GREETING_REQUEST_REQ)1 GREETING_REQUEST_REQ2 (io.scalecube.services.TestRequests.GREETING_REQUEST_REQ2)1 ServiceMessage (io.scalecube.services.api.ServiceMessage)1 ScalecubeServiceDiscovery (io.scalecube.services.discovery.ScalecubeServiceDiscovery)1 RandomServiceRouter (io.scalecube.services.routing.RandomServiceRouter)1 Routers (io.scalecube.services.routing.Routers)1 CanaryService (io.scalecube.services.routings.sut.CanaryService)1 DummyRouter (io.scalecube.services.routings.sut.DummyRouter)1 GreetingServiceImplA (io.scalecube.services.routings.sut.GreetingServiceImplA)1 GreetingServiceImplB (io.scalecube.services.routings.sut.GreetingServiceImplB)1 TagService (io.scalecube.services.routings.sut.TagService)1 WeightedRandomRouter (io.scalecube.services.routings.sut.WeightedRandomRouter)1 GreetingRequest (io.scalecube.services.sut.GreetingRequest)1