io.tarantool.driver.api.space.options.OperationWithTimeoutOptions Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cartridge-driver Show documentation
Show all versions of cartridge-driver Show documentation
Tarantool Cartridge driver for Tarantool versions 1.10+ based on Netty framework
package io.tarantool.driver.api.space.options;
import java.util.Optional;
/**
* Base class for all operation options that may have a configurable timeout.
*
* @author Alexey Kuzin
*/
public interface OperationWithTimeoutOptions> extends Options, Self {
String TIMEOUT = "timeout";
/**
* Specifies timeout for waiting for a server response for the operation.
* Configured request timeout for that client will be used by default.
*
* @param timeout request timeout, in milliseconds
* @return this options instance
*/
default T withTimeout(int timeout) {
if (timeout <= 0) {
throw new IllegalArgumentException("Timeout should be greater than 0");
}
addOption(TIMEOUT, timeout);
return self();
}
/**
* Return operation timeout.
*
* @return timeout, in milliseconds.
*/
default Optional getTimeout() {
return getOption(TIMEOUT, Integer.class);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy