io.tarantool.driver.proxy.UpdateProxyOperation 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.proxy;
import io.tarantool.driver.TarantoolClientConfig;
import io.tarantool.driver.api.TarantoolClient;
import io.tarantool.driver.protocol.TarantoolIndexQuery;
import io.tarantool.driver.mappers.TarantoolCallResultMapper;
import io.tarantool.driver.api.tuple.operations.TupleOperations;
import io.tarantool.driver.utils.Assert;
import java.util.Arrays;
import java.util.List;
/**
* Proxy operation for update
*
* @param tuple result type
* @author Sergey Volgin
*/
public final class UpdateProxyOperation extends AbstractProxyOperation {
UpdateProxyOperation(TarantoolClient client,
String functionName,
List> arguments,
TarantoolCallResultMapper resultMapper) {
super(client, functionName, arguments, resultMapper);
}
/**
* The builder for this class.
*/
public static final class Builder {
private TarantoolClient client;
private String spaceName;
private String functionName;
private TarantoolIndexQuery indexQuery;
private TupleOperations operations;
private TarantoolCallResultMapper resultMapper;
public Builder() {
}
public Builder withClient(TarantoolClient client) {
this.client = client;
return this;
}
public Builder withSpaceName(String spaceName) {
this.spaceName = spaceName;
return this;
}
public Builder withFunctionName(String functionName) {
this.functionName = functionName;
return this;
}
public Builder withIndexQuery(TarantoolIndexQuery indexQuery) {
this.indexQuery = indexQuery;
return this;
}
public Builder withTupleOperation(TupleOperations operations) {
this.operations = operations;
return this;
}
public Builder withResultMapper(TarantoolCallResultMapper resultMapper) {
this.resultMapper = resultMapper;
return this;
}
public UpdateProxyOperation build() {
Assert.notNull(client, "Tarantool client should not be null");
Assert.notNull(spaceName, "Tarantool spaceName should not be null");
Assert.notNull(functionName, "Proxy delete function name should not be null");
Assert.notNull(indexQuery, "Tarantool indexQuery should not be null");
Assert.notNull(operations, "Tarantool tuple operations should not be null");
Assert.notNull(resultMapper, "Result tuple mapper should not be null");
TarantoolClientConfig config = client.getConfig();
CRUDOperationOptions options = CRUDOperationOptions.builder()
.withTimeout(config.getRequestTimeout())
.build();
List> arguments = Arrays.asList(spaceName,
indexQuery.getKeyValues(),
operations.asProxyOperationList(),
options.asMap());
return new UpdateProxyOperation(this.client, this.functionName, arguments, this.resultMapper);
}
}
}