Module io.inverno.mod.discovery.http


module io.inverno.mod.discovery.http

The Inverno framework HTTP service discovery module defines the API for HTTP service discovery and provides the DNS based HTTP discovery service.

It defines the following sockets:

httpClient (required)
the HTTP client used to create endpoints
netService (required)
the Net service used for DNS lookups

It exposes the following beans:

dnsHttpDiscoveryService
the DNS based HTTP discovery service

The DNS based HTTP discovery service is typically used to resolve standard http://, https://, ws:// or wss:// service URIs.


 HttpClient httpClient = ...
 NetService netService = ...

 Http discoveryHttpModule = new Http.Builder(httpClient, netService).build();
 try {
     discoveryHttpModule.start();

     httpClient.exchange("/")
         .flatMap(exchange -> discoveryHttpModule.dnsHttpDiscoveryService().resolve(ServiceId.of("http://example.org")) // resolve the 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 {
     discoveryHttpModule.stop();
 }
 
Since:
1.12
Author:
Jeremy Kuhn