public interface ServiceLocator
doWithService(String, Descriptor.Call, Function)
is invoked.
The reason circuit breaking is a service locator concern is that generally, the service locator will want to be aware
of when a circuit breaker is open, and respond accordingly. For example, it may decide to pull that node from its
routing pool, or it may decide to notify some up stream service registry that that node is no longer responding.Modifier and Type | Method and Description |
---|---|
<T> java.util.concurrent.CompletionStage<java.util.Optional<T>> |
doWithService(String name,
Descriptor.Call<?,?> serviceCall,
java.util.function.Function<java.net.URI,java.util.concurrent.CompletionStage<T>> block)
Do the given action with the given service.
|
default java.util.concurrent.CompletionStage<java.util.Optional<java.net.URI>> |
locate(String name)
Locate a service with the given name.
|
java.util.concurrent.CompletionStage<java.util.Optional<java.net.URI>> |
locate(String name,
Descriptor.Call<?,?> serviceCall)
Locate a service with the given name.
|
default java.util.concurrent.CompletionStage<java.util.Optional<java.net.URI>> locate(String name)
name
- The name of the service.java.util.concurrent.CompletionStage<java.util.Optional<java.net.URI>> locate(String name, Descriptor.Call<?,?> serviceCall)
name
- The name of the service.serviceCall
- The service call descriptor that this lookup is for.<T> java.util.concurrent.CompletionStage<java.util.Optional<T>> doWithService(String name, Descriptor.Call<?,?> serviceCall, java.util.function.Function<java.net.URI,java.util.concurrent.CompletionStage<T>> block)
locate(String, Descriptor.Call)
when possible as it will allow the
service locator to add in things like circuit breakers.
It is required that the service locator will, based on the service call circuit breaker configuration, wrap the
invocation of the passed in block with a circuit breaker.name
- The name of the service.serviceCall
- The service call descriptor that this lookup is for.block
- A block of code that takes the URI for the service, and returns a future of some work done on the
service. This will only be executed if the service was found.