use of io.scalecube.services.ServiceReference in project scalecube by scalecube.
the class RoutersTest method tesTagsFromAnnotation.
@Test
public void tesTagsFromAnnotation() {
ServiceCall serviceCall = provider3.call().router((req, mes) -> {
ServiceReference tagServiceRef = req.listServiceReferences().get(0);
Map<String, String> tags = tagServiceRef.tags();
assertEquals(new HashSet<>(asList("tagA", "tagB", "tagC", "methodTagA")), tags.keySet());
assertEquals("a", tags.get("tagA"));
// user override this tag in Microservices#services
assertEquals("bb", tags.get("tagB"));
assertEquals("c", tags.get("tagC"));
assertEquals("a", tags.get("methodTagA"));
return Optional.of(tagServiceRef);
});
serviceCall.api(TagService.class).upperCase(Flux.just("hello")).blockLast();
}
use of io.scalecube.services.ServiceReference in project scalecube by scalecube.
the class ServiceRegistryImpl method unregisterService.
@Override
public ServiceEndpoint unregisterService(String endpointId) {
ServiceEndpoint serviceEndpoint = serviceEndpoints.remove(endpointId);
if (serviceEndpoint != null) {
LOGGER.debug("ServiceEndpoint unregistered: {}", serviceEndpoint);
List<ServiceReference> serviceReferencesOfEndpoint = serviceReferencesByQualifier.values().stream().flatMap(Collection::stream).filter(sr -> sr.endpointId().equals(endpointId)).collect(Collectors.toList());
serviceReferencesOfEndpoint.forEach(sr -> {
computeServiceReferences(sr.qualifier(), sr);
computeServiceReferences(sr.oldQualifier(), sr);
});
}
return serviceEndpoint;
}
use of io.scalecube.services.ServiceReference in project scalecube by scalecube.
the class RSocketClientTransport method create.
@Override
public ClientChannel create(ServiceReference serviceReference) {
// keep reference for threadsafety
final Map<Address, Mono<RSocket>> monoMap = rsockets.get();
final Address address = serviceReference.address();
Mono<RSocket> mono = monoMap.computeIfAbsent(address, key -> getCredentials(serviceReference).flatMap(creds -> connect(key, creds, monoMap)).cache().doOnError(ex -> monoMap.remove(key)));
return new RSocketClientChannel(mono, new ServiceMessageCodec(headersCodec, dataCodecs));
}
Aggregations