Module io.inverno.mod.discovery.http.meta


module io.inverno.mod.discovery.http.meta

The Inverno framework HTTP meta service discovery module defines the meta HTTP service API and provides a configuration based HTTP meta service discovery service.

An HTTP meta service composes multiple HTTP services defined as destinations in one or more routes defining the criteria (path, authority, headers...) matched by a given HTTP request to be routed to a particular set of destinations as well as load balancing strategy, request/response transformation, HTTP client configuration...

The module defines the following sockets:

serviceConfigurationSource (required)
a configuration source exposing HTTP meta service descriptors
configuration
the HTTP discovery meta module configuration
discoveryServices
the external discovery services used to resolve HTTP meta service destinations
objectMapper
an object mapper to read JSON HTTP meta service descriptors

It exposes the following beans:

configuration
the HTTP discovery meta module configuration
configurationHttpMetaDiscoveryService
the configuration HTTP meta service discovery service

The configuration HTTP meta service discovery service resolves services from service descriptors defined in a configuration source, a configuration HTTP meta service URI being of the form conf://<service_name>.


 ConfigurationSource serviceConfigurationSource = ...
 HttpDiscoveryService dnsHttpDiscoveryService = ...

 Meta discoveryHttpMetaModule = new Meta.Builder(serviceConfigurationSource)
     .setDiscoveryServices(List.of(dnsHttpDiscoveryService))
     .build();
 try {
     discoveryHttpMetaModule.start();

     httpClient.exchange("/")
         .flatMap(exchange -> discoveryHttpMetaModule.configurationHttpMetaDiscoveryService().resolve(ServiceId.of("conf://sampleService")) // resolve the meta service
              .flatMap(service -> service.getInstance(exchange))                                                                            // get an instance
              .map(serviceInstance -> serviceInstance.bind(exchange))                                                                       // bind the exchange to the instance
          )
          .flatMap(Exchange::response)                                                                                                      // send the request
          ...
 }
 finally {
     discoveryHttpMetaModule.stop();
 }
 
Since:
1.12
Author:
Jeremy Kuhn