com.netflix.hystrix
Interface HystrixExecutable<R>

Type Parameters:
R -
All Known Implementing Classes:
HystrixCollapser, HystrixCommand

public interface HystrixExecutable<R>

Common interface for executables (HystrixCommand and HystrixCollapser) so client code can treat them the same and combine in typed collections if desired.


Method Summary
 R execute()
          Used for synchronous execution of command.
 java.util.concurrent.Future<R> queue()
          Used for asynchronous execution of command.
 

Method Detail

execute

R execute()
Used for synchronous execution of command.

Returns:
R Result of HystrixCommand execution
Throws:
HystrixRuntimeException - if an error occurs and a fallback cannot be retrieved
HystrixBadRequestException - if the HystrixCommand instance considers request arguments to be invalid and needs to throw an error that does not represent a system failure

queue

java.util.concurrent.Future<R> queue()
Used for asynchronous execution of command.

This will queue up the command on the thread pool and return an Future to get the result once it completes.

NOTE: If configured to not run in a separate thread, this will have the same effect as HystrixExecutable.execute() and will block.

We don't throw an exception in that case but just flip to synchronous execution so code doesn't need to change in order to switch a circuit from running a separate thread to the calling thread.

Returns:
Future<R> Result of HystrixCommand execution
Throws:
HystrixRuntimeException - if an error occurs and a fallback cannot be retrieved
HystrixBadRequestException - if the HystrixCommand instance considers request arguments to be invalid and needs to throw an error that does not represent a system failure