All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.tarantool.driver.api.space.options.OperationWithTimeoutOptions Maven / Gradle / Ivy

Go to download

Tarantool Cartridge driver for Tarantool versions 1.10+ based on Netty framework

There is a newer version: 0.14.0
Show newest version
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