Module io.inverno.mod.discovery
Package io.inverno.mod.discovery
Class AbstractConfigurationDiscoveryService<A extends ServiceInstance,B,C extends TrafficPolicy<A,B>,D>
java.lang.Object
io.inverno.mod.discovery.AbstractDiscoveryService<A,B,C>
io.inverno.mod.discovery.AbstractConfigurationDiscoveryService<A,B,C,D>
- Type Parameters:
A
- the type of service instanceB
- the type of service requestC
- the type of traffic policyD
- the service descriptor type
- All Implemented Interfaces:
DiscoveryService<A,
B, C>
public abstract class AbstractConfigurationDiscoveryService<A extends ServiceInstance,B,C extends TrafficPolicy<A,B>,D>
extends AbstractDiscoveryService<A,B,C>
Base configuration based discovery service implementation.
Service descriptors specifying the service instances and traffic policy are resolved from a ConfigurationSource
and unmarshalled using readServiceDescriptor(String)
. They are then used
to actually create the service using createService(ServiceID, Mono)
.
- Since:
- 1.12
- Author:
- Jeremy Kuhn
-
Constructor Summary
ConstructorDescriptionAbstractConfigurationDiscoveryService
(Set<String> supportedSchemes, String serviceKeyPrefix, ConfigurationSource configurationSource) Creates a configuration discovery service. -
Method Summary
Modifier and TypeMethodDescriptioncreateService
(ServiceID serviceId, Mono<D> serviceDescriptor) Creates a service from service descriptor.Resolves a service.protected abstract D
readServiceDescriptor
(String content) Deserializes the service descriptor retrieved from configuration.Methods inherited from class io.inverno.mod.discovery.AbstractDiscoveryService
getSupportedSchemes, resolve
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.inverno.mod.discovery.DiscoveryService
supports, supports, supports
-
Constructor Details
-
AbstractConfigurationDiscoveryService
public AbstractConfigurationDiscoveryService(Set<String> supportedSchemes, String serviceKeyPrefix, ConfigurationSource configurationSource) Creates a configuration discovery service.
- Parameters:
supportedSchemes
- the set of supported schemesserviceKeyPrefix
- the prefix to prepend to the service name when retrieving descriptors from configurationconfigurationSource
- the configuration source
-
-
Method Details
-
doResolve
protected final Mono<? extends Service<A,B, doResolveC>> (ServiceID serviceId, C trafficPolicy) throws MalformedServiceDescriptorException Description copied from class:AbstractDiscoveryService
Resolves a service.
This is basically invoked by
AbstractDiscoveryService.resolve(ServiceID, TrafficPolicy)
after validating that the service ID scheme is supported.- Specified by:
doResolve
in classAbstractDiscoveryService<A extends ServiceInstance,
B, C extends TrafficPolicy<A, B>> - Parameters:
serviceId
- a service IDtrafficPolicy
- a traffic policy- Returns:
- a
Mono
emitting the resolved service or an emptyMono
if no service could be resolved - Throws:
MalformedServiceDescriptorException
-
readServiceDescriptor
Deserializes the service descriptor retrieved from configuration.
- Parameters:
content
- the descriptor content- Returns:
- service descriptor
- Throws:
Exception
- if there was an error reading the descriptor content
-
createService
Creates a service from service descriptor.
- Parameters:
serviceId
- the service IDserviceDescriptor
- the service descriptor- Returns:
- a service
-