use of io.lettuce.core.dynamic.domain.Timeout in project lettuce-core by lettuce-io.
the class AsyncExecutableCommand method dispatchCommand.
protected Object dispatchCommand(Object[] arguments, RedisCommand<Object, Object, Object> command) throws InterruptedException, java.util.concurrent.ExecutionException {
AsyncCommand<Object, Object, Object> asyncCommand = new AsyncCommand<>(command);
if (commandMethod.isFutureExecution()) {
RedisCommand<Object, Object, Object> dispatched = connection.dispatch(asyncCommand);
if (dispatched instanceof AsyncCommand) {
return dispatched;
}
return asyncCommand;
}
connection.dispatch(asyncCommand);
Duration timeout = connection.getTimeout();
if (commandMethod.getParameters() instanceof ExecutionSpecificParameters) {
ExecutionSpecificParameters executionSpecificParameters = (ExecutionSpecificParameters) commandMethod.getParameters();
if (executionSpecificParameters.hasTimeoutIndex()) {
Timeout timeoutArg = (Timeout) arguments[executionSpecificParameters.getTimeoutIndex()];
if (timeoutArg != null) {
timeout = timeoutArg.getTimeout();
}
}
}
Futures.await(timeout, asyncCommand);
return asyncCommand.get();
}
use of io.lettuce.core.dynamic.domain.Timeout in project lettuce-core by lettuce-io.
the class CommandSegmentCommandFactoryUnitTests method asyncWithTimeout.
@Test
void asyncWithTimeout() {
try {
createCommand(methodOf(MethodsWithTimeout.class, "async", String.class, Timeout.class), new StringCodec());
fail("Missing CommandCreationException");
} catch (CommandCreationException e) {
assertThat(e).hasMessageContaining("Asynchronous command methods do not support Timeout parameters");
}
}
Aggregations