Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update FUNCTION LOAD changes (from release 7.0 rc3) #2973

Merged
merged 5 commits into from
Apr 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions src/main/java/redis/clients/jedis/CommandObjects.java
Original file line number Diff line number Diff line change
Expand Up @@ -2821,14 +2821,12 @@ public final CommandObject<List<LibraryInfo>> functionListWithCode(String librar
.add(libraryNamePattern).add(WITHCODE), BuilderFactory.LIBRARY_LIST);
}

public final CommandObject<String> functionLoad(String engineName, String libraryName, String functionCode) {
return new CommandObject<>(commandArguments(FUNCTION).add(LOAD).add(engineName)
.add(libraryName).add(functionCode), BuilderFactory.STRING);
public final CommandObject<String> functionLoad(String functionCode) {
return new CommandObject<>(commandArguments(FUNCTION).add(LOAD).add(functionCode), BuilderFactory.STRING);
}

public final CommandObject<String> functionLoad(String engineName, String libraryName, FunctionLoadParams params, String functionCode) {
return new CommandObject<>(commandArguments(FUNCTION).add(LOAD).add(engineName)
.add(libraryName).addParams(params).add(functionCode), BuilderFactory.STRING);
public final CommandObject<String> functionLoadReplace(String functionCode) {
return new CommandObject<>(commandArguments(FUNCTION).add(LOAD).add(REPLACE).add(functionCode), BuilderFactory.STRING);
}

public final CommandObject<FunctionStats> functionStats() {
Expand Down Expand Up @@ -2893,14 +2891,12 @@ public final CommandObject<List<Object>> functionListWithCode(byte[] libraryName
add(libraryNamePattern).add(WITHCODE), BuilderFactory.RAW_OBJECT_LIST);
}

public final CommandObject<String> functionLoad(byte[] engineName, byte[] libraryName, byte[] functionCode) {
return new CommandObject<>(commandArguments(FUNCTION).add(LOAD).add(engineName)
.add(libraryName).add(functionCode), BuilderFactory.STRING);
public final CommandObject<String> functionLoad(byte[] functionCode) {
return new CommandObject<>(commandArguments(FUNCTION).add(LOAD).add(functionCode), BuilderFactory.STRING);
}

public final CommandObject<String> functionLoad(byte[] engineName, byte[] libraryName, FunctionLoadParams params, byte[] functionCode) {
return new CommandObject<>(commandArguments(FUNCTION).add(LOAD).add(engineName)
.add(libraryName).addParams(params).add(functionCode), BuilderFactory.STRING);
public final CommandObject<String> functionLoadReplace(byte[] functionCode) {
return new CommandObject<>(commandArguments(FUNCTION).add(LOAD).add(REPLACE).add(functionCode), BuilderFactory.STRING);
}

public final CommandObject<String> functionRestore(byte[] serializedValue) {
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/redis/clients/jedis/Jedis.java
Original file line number Diff line number Diff line change
Expand Up @@ -8843,15 +8843,15 @@ public String functionDelete(final String libraryName) {
}

@Override
public String functionLoad(final String engineName, final String libraryName, final String functionCode) {
public String functionLoad(final String functionCode) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.functionLoad(engineName, libraryName, functionCode));
return connection.executeCommand(commandObjects.functionLoad(functionCode));
}

@Override
public String functionLoad(final String engineName, final String libraryName, final FunctionLoadParams params, final String functionCode) {
public String functionLoadReplace(final String functionCode) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.functionLoad(engineName, libraryName, params, functionCode));
return connection.executeCommand(commandObjects.functionLoadReplace(functionCode));
}

@Override
Expand Down Expand Up @@ -9447,15 +9447,15 @@ public List<Object> functionListWithCode(final byte[] libraryNamePattern) {
}

@Override
public String functionLoad(final byte[] engineName, final byte[] libraryName, final byte[] functionCode) {
public String functionLoad(final byte[] functionCode) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.functionLoad(engineName, libraryName, functionCode));
return connection.executeCommand(commandObjects.functionLoad(functionCode));
}

@Override
public String functionLoad(final byte[] engineName, final byte[] libraryName, final FunctionLoadParams params, final byte[] functionCode) {
public String functionLoadReplace(final byte[] functionCode) {
checkIsInMultiOrPipeline();
return connection.executeCommand(commandObjects.functionLoad(engineName, libraryName, params, functionCode));
return connection.executeCommand(commandObjects.functionLoadReplace(functionCode));
}

@Override
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/redis/clients/jedis/MultiNodePipelineBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -1734,23 +1734,23 @@ public Response<List<Object>> functionListWithCode(final byte[] libraryNamePatte
}

@Override
public Response<String> functionLoad(byte[] engineName, byte[] libraryName, byte[] functionCode) {
return appendCommand(commandObjects.functionLoad(engineName, libraryName, functionCode));
public Response<String> functionLoad(byte[] functionCode) {
return appendCommand(commandObjects.functionLoad(functionCode));
}

@Override
public Response<String> functionLoad(String engineName, String libraryName, String functionCode) {
return appendCommand(commandObjects.functionLoad(engineName, libraryName, functionCode));
public Response<String> functionLoad(String functionCode) {
return appendCommand(commandObjects.functionLoad(functionCode));
}

@Override
public Response<String> functionLoad(byte[] engineName, byte[] libraryName, FunctionLoadParams params, byte[] functionCode) {
return appendCommand(commandObjects.functionLoad(engineName, libraryName, params, functionCode));
public Response<String> functionLoadReplace(byte[] functionCode) {
return appendCommand(commandObjects.functionLoadReplace(functionCode));
}

@Override
public Response<String> functionLoad(String engineName, String libraryName, FunctionLoadParams params, String functionCode) {
return appendCommand(commandObjects.functionLoad(engineName, libraryName, params, functionCode));
public Response<String> functionLoadReplace(String functionCode) {
return appendCommand(commandObjects.functionLoadReplace(functionCode));
}

@Override
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/redis/clients/jedis/Pipeline.java
Original file line number Diff line number Diff line change
Expand Up @@ -1736,23 +1736,23 @@ public Response<List<Object>> functionListWithCode(final byte[] libraryNamePatte
}

@Override
public Response<String> functionLoad(byte[] engineName, byte[] libraryName, byte[] functionCode) {
return appendCommand(commandObjects.functionLoad(engineName, libraryName, functionCode));
public Response<String> functionLoad(byte[] functionCode) {
return appendCommand(commandObjects.functionLoad(functionCode));
}

@Override
public Response<String> functionLoad(String engineName, String libraryName, String functionCode) {
return appendCommand(commandObjects.functionLoad(engineName, libraryName, functionCode));
public Response<String> functionLoad(String functionCode) {
return appendCommand(commandObjects.functionLoad(functionCode));
}

@Override
public Response<String> functionLoad(byte[] engineName, byte[] libraryName, FunctionLoadParams params, byte[] functionCode) {
return appendCommand(commandObjects.functionLoad(engineName, libraryName, params, functionCode));
public Response<String> functionLoadReplace(byte[] functionCode) {
return appendCommand(commandObjects.functionLoadReplace(functionCode));
}

@Override
public Response<String> functionLoad(String engineName, String libraryName, FunctionLoadParams params, String functionCode) {
return appendCommand(commandObjects.functionLoad(engineName, libraryName, params, functionCode));
public Response<String> functionLoadReplace(String functionCode) {
return appendCommand(commandObjects.functionLoadReplace(functionCode));
}

@Override
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/redis/clients/jedis/TransactionBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -1803,23 +1803,23 @@ public Response<List<Object>> functionListWithCode(final byte[] libraryNamePatte
}

@Override
public Response<String> functionLoad(byte[] engineName, byte[] libraryName, byte[] functionCode) {
return appendCommand(commandObjects.functionLoad(engineName, libraryName, functionCode));
public Response<String> functionLoad(byte[] functionCode) {
return appendCommand(commandObjects.functionLoad(functionCode));
}

@Override
public Response<String> functionLoad(String engineName, String libraryName, String functionCode) {
return appendCommand(commandObjects.functionLoad(engineName, libraryName, functionCode));
public Response<String> functionLoad(String functionCode) {
return appendCommand(commandObjects.functionLoad(functionCode));
}

@Override
public Response<String> functionLoad(byte[] engineName, byte[] libraryName, FunctionLoadParams params, byte[] functionCode) {
return appendCommand(commandObjects.functionLoad(engineName, libraryName, params, functionCode));
public Response<String> functionLoadReplace(byte[] functionCode) {
return appendCommand(commandObjects.functionLoadReplace(functionCode));
}

@Override
public Response<String> functionLoad(String engineName, String libraryName, FunctionLoadParams params, String functionCode) {
return appendCommand(commandObjects.functionLoad(engineName, libraryName, params, functionCode));
public Response<String> functionLoadReplace(String functionCode) {
return appendCommand(commandObjects.functionLoadReplace(functionCode));
}

@Override
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/redis/clients/jedis/UnifiedJedis.java
Original file line number Diff line number Diff line change
Expand Up @@ -3140,13 +3140,13 @@ public List<LibraryInfo> functionListWithCode(String libraryNamePattern) {
}

@Override
public String functionLoad(String engineName, String libraryName, String functionCode) {
return executeCommand(commandObjects.functionLoad(engineName, libraryName, functionCode));
public String functionLoad(String functionCode) {
return executeCommand(commandObjects.functionLoad(functionCode));
}

@Override
public String functionLoad(String engineName, String libraryName, FunctionLoadParams params, String functionCode) {
return executeCommand(commandObjects.functionLoad(engineName, libraryName, params, functionCode));
public String functionLoadReplace(String functionCode) {
return executeCommand(commandObjects.functionLoadReplace(functionCode));
}

@Override
Expand Down Expand Up @@ -3195,13 +3195,13 @@ public List<Object> functionListWithCode(final byte[] libraryNamePattern) {
}

@Override
public String functionLoad(byte[] engineName, byte[] libraryName, byte[] functionCode) {
return executeCommand(commandObjects.functionLoad(engineName, libraryName, functionCode));
public String functionLoad(byte[] functionCode) {
return executeCommand(commandObjects.functionLoad(functionCode));
}

@Override
public String functionLoad(byte[] engineName, byte[] libraryName, FunctionLoadParams params, byte[] functionCode) {
return executeCommand(commandObjects.functionLoad(engineName, libraryName, params, functionCode));
public String functionLoadReplace(byte[] functionCode) {
return executeCommand(commandObjects.functionLoadReplace(functionCode));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import redis.clients.jedis.args.FlushMode;
import redis.clients.jedis.args.FunctionRestorePolicy;
import redis.clients.jedis.params.FunctionLoadParams;
import redis.clients.jedis.resps.FunctionStats;
import redis.clients.jedis.resps.LibraryInfo;

Expand Down Expand Up @@ -89,22 +88,21 @@ public interface FunctionBinaryCommands {

/**
* Load a library to Redis.
* @param engineName the name of the execution engine for the library
* @param libraryName the unique name of the library
* @param functionCode the source code
* @return OK
* @param functionCode the source code. The library payload must start
* with Shebang statement that provides a metadata
* about the library (like the engine to use and the library name).
* Shebang format: #!<engine name> name=<library name>.
* Currently engine name must be lua.
* @return The library name that was loaded
*/
String functionLoad(byte[] engineName, byte[] libraryName, byte[] functionCode);
String functionLoad(byte[] functionCode);

/**
* Load a library to Redis.
* @param engineName the name of the execution engine for the library
* @param libraryName the unique name of the library
* @param params {@link FunctionLoadParams}
* Load a library to Redis. Will replace the current library if it already exists.
* @param functionCode the source code
* @return OK
* @return The library name that was loaded
*/
String functionLoad(byte[] engineName, byte[] libraryName, FunctionLoadParams params, byte[] functionCode);
String functionLoadReplace(byte[] functionCode);

/**
* Restore libraries from the serialized payload. Default policy is APPEND.
Expand Down
22 changes: 10 additions & 12 deletions src/main/java/redis/clients/jedis/commands/FunctionCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import redis.clients.jedis.args.FlushMode;
import redis.clients.jedis.args.FunctionRestorePolicy;
import redis.clients.jedis.params.FunctionLoadParams;
import redis.clients.jedis.resps.FunctionStats;
import redis.clients.jedis.resps.LibraryInfo;

Expand Down Expand Up @@ -93,22 +92,21 @@ public interface FunctionCommands {

/**
* Load a library to Redis.
* @param engineName the name of the execution engine for the library
* @param libraryName the unique name of the library
* @param functionCode the source code
* @return OK
* @param functionCode the source code. The library payload must start
* with Shebang statement that provides a metadata
* about the library (like the engine to use and the library name).
* Shebang format: #!<engine name> name=<library name>.
* Currently engine name must be lua.
* @return The library name that was loaded
*/
String functionLoad(String engineName, String libraryName, String functionCode);
String functionLoad(String functionCode);

/**
* Load a library to Redis.
* @param engineName the name of the execution engine for the library
* @param libraryName the unique name of the library
* @param params {@link FunctionLoadParams}
* Load a library to Redis. Will replace the current library if it already exists.
* @param functionCode the source code
* @return OK
* @return The library name that was loaded
*/
String functionLoad(String engineName, String libraryName, FunctionLoadParams params, String functionCode);
String functionLoadReplace(String functionCode);

/**
* Restore libraries from the serialized payload. Default policy is APPEND.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import redis.clients.jedis.Response;
import redis.clients.jedis.args.FlushMode;
import redis.clients.jedis.args.FunctionRestorePolicy;
import redis.clients.jedis.params.FunctionLoadParams;

import java.util.List;

Expand Down Expand Up @@ -31,9 +30,9 @@ public interface FunctionPipelineBinaryCommands {

Response<List<Object>> functionListWithCode(byte[] libraryNamePattern);

Response<String> functionLoad(byte[] engineName, byte[] libraryName, byte[] functionCode);
Response<String> functionLoad(byte[] functionCode);

Response<String> functionLoad(byte[] engineName, byte[] libraryName, FunctionLoadParams params, byte[] functionCode);
Response<String> functionLoadReplace(byte[] functionCode);

Response<String> functionRestore(byte[] serializedValue);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import redis.clients.jedis.Response;
import redis.clients.jedis.args.FlushMode;
import redis.clients.jedis.args.FunctionRestorePolicy;
import redis.clients.jedis.params.FunctionLoadParams;
import redis.clients.jedis.resps.FunctionStats;
import redis.clients.jedis.resps.LibraryInfo;

Expand Down Expand Up @@ -33,9 +32,9 @@ public interface FunctionPipelineCommands {

Response<List<LibraryInfo>> functionListWithCode(String libraryNamePattern);

Response<String> functionLoad(String engineName, String libraryName, String functionCode);
Response<String> functionLoad(String functionCode);

Response<String> functionLoad(String engineName, String libraryName, FunctionLoadParams params, String functionCode);
Response<String> functionLoadReplace(String functionCode);

Response<String> functionRestore(byte[] serializedValue);

Expand Down
41 changes: 0 additions & 41 deletions src/main/java/redis/clients/jedis/params/FunctionLoadParams.java

This file was deleted.

Loading