public abstract class CircuitBreakingServiceLocator extends Object implements ServiceLocator
Generally, only the ServiceLocator.locate(String, Descriptor.Call)
method needs to be implemented,
however doWithServiceImpl(String, Descriptor.Call, Function)
can be overridden if the
service locator wants to handle failures in some way.
Constructor and Description |
---|
CircuitBreakingServiceLocator(com.lightbend.lagom.internal.client.CircuitBreakers circuitBreakers)
Deprecated.
Use constructor accepting
CircuitBreakersPanel instead |
CircuitBreakingServiceLocator(CircuitBreakersPanel circuitBreakersPanel) |
Modifier and Type | Method and Description |
---|---|
<T> CompletionStage<Optional<T>> |
doWithService(String serviceName,
Descriptor.Call<?,?> serviceCall,
Function<URI,CompletionStage<T>> block)
Do the given action with the given service.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
locate, locate, locateAll, locateAll
public CircuitBreakingServiceLocator(CircuitBreakersPanel circuitBreakersPanel)
@Deprecated public CircuitBreakingServiceLocator(com.lightbend.lagom.internal.client.CircuitBreakers circuitBreakers)
CircuitBreakersPanel
insteadcircuitBreakers
- public final <T> CompletionStage<Optional<T>> doWithService(String serviceName, Descriptor.Call<?,?> serviceCall, Function<URI,CompletionStage<T>> block)
ServiceLocator
This should be used in preference to ServiceLocator.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.
doWithService
in interface ServiceLocator
serviceName
- 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.